Header parsing
This commit is contained in:
+13
-1
@@ -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(
|
||||
¤t_token.children,
|
||||
Token{TokenType.Header, header_level, nil, current_token},
|
||||
)
|
||||
current_token = ¤t_token.children[len(current_token.children) - 1]
|
||||
append(¤t_token.children, Token{TokenType.Text, text, nil, current_token})
|
||||
current_token = current_token.parent
|
||||
continue
|
||||
}
|
||||
|
||||
append(¤t_token.children, Token{TokenType.Text, line, nil, current_token})
|
||||
|
||||
// lvl, text := parse_header(trimmed)
|
||||
|
||||
Reference in New Issue
Block a user