Header parsing

This commit is contained in:
2026-07-13 23:52:37 +02:00
parent aad1cfcc07
commit beabb0a0e4
2 changed files with 15 additions and 3 deletions
+13 -1
View File
@@ -8,7 +8,7 @@ TokenType :: enum {
Italics,
Bold,
BreakLine,
Heading,
Header,
Paragraph,
Root,
}
@@ -69,6 +69,18 @@ parse :: proc(lines: []string, allocator := context.allocator) -> Token {
continue
}
header_level, text := parse_header(line)
if header_level > 0 {
append(
&current_token.children,
Token{TokenType.Header, header_level, nil, current_token},
)
current_token = &current_token.children[len(current_token.children) - 1]
append(&current_token.children, Token{TokenType.Text, text, nil, current_token})
current_token = current_token.parent
continue
}
append(&current_token.children, Token{TokenType.Text, line, nil, current_token})
// lvl, text := parse_header(trimmed)