diff --git a/README.tlm b/README.tlm index 9df9e51..e029ddc 100644 --- a/README.tlm +++ b/README.tlm @@ -47,5 +47,7 @@ main :: proc() { } ``` +--- + [&1] Ordered list item 2 not included [&named] This is the definition for a named footnote diff --git a/src/html.odin b/src/html.odin index a53ddbc..42196de 100644 --- a/src/html.odin +++ b/src/html.odin @@ -210,6 +210,9 @@ print_html :: proc(token: ^Token) { fmt.printf("%s", code) } + case TokenType.HorizontalRule: + fmt.print("
\n") + case TokenType.BreakLine: fmt.print("
\n") diff --git a/src/main.odin b/src/main.odin index ee6a502..8c8b20e 100644 --- a/src/main.odin +++ b/src/main.odin @@ -63,6 +63,8 @@ print_token :: proc(token: ^Token, depth: int = 0) { type_str = "CodeBlock" case TokenType.InlineCode: type_str = "InlineCode" + case TokenType.HorizontalRule: + type_str = "HorizontalRule" } value_str := "" diff --git a/src/parser.odin b/src/parser.odin index b567152..569495b 100644 --- a/src/parser.odin +++ b/src/parser.odin @@ -28,6 +28,7 @@ TokenType :: enum { FootnoteRef, CodeBlock, InlineCode, + HorizontalRule, } TokenValue :: union { @@ -407,6 +408,27 @@ parse :: proc(lines: []string, allocator := context.allocator) -> Token { continue } + if len(line) >= 3 { + is_hr := true + ch := line[0] + if ch == '-' || ch == '_' || ch == '=' { + for i := 1; i < len(line); i += 1 { + if line[i] != ch { + is_hr = false + break + } + } + } else { + is_hr = false + } + + if is_hr { + push_token(&root, TokenType.HorizontalRule, nil) + current_token = &root + continue + } + } + if len(line) == 0 { current_token = &root continue