Unordered lists
This commit is contained in:
@@ -31,6 +31,12 @@ print_token :: proc(token: ^Token, depth: int = 0) {
|
||||
type_str = "Paragraph"
|
||||
case TokenType.Blockquote:
|
||||
type_str = "Blockquote"
|
||||
case TokenType.UnorderedList:
|
||||
type_str = "UnorderedList"
|
||||
case TokenType.OrderedList:
|
||||
type_str = "OrderedList"
|
||||
case TokenType.ListItem:
|
||||
type_str = "ListItem"
|
||||
}
|
||||
|
||||
value_str := ""
|
||||
|
||||
@@ -11,6 +11,9 @@ TokenType :: enum {
|
||||
Paragraph,
|
||||
Root,
|
||||
Blockquote,
|
||||
UnorderedList,
|
||||
OrderedList,
|
||||
ListItem,
|
||||
}
|
||||
|
||||
TokenValue :: union {
|
||||
@@ -79,6 +82,16 @@ parse :: proc(lines: []string, allocator := context.allocator) -> Token {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.has_prefix(text, ". ") || strings.has_prefix(text, "- ") {
|
||||
if current_token.type != TokenType.UnorderedList {
|
||||
current_token = push_token(&root, TokenType.UnorderedList, nil)
|
||||
}
|
||||
current_token = push_token(current_token, TokenType.ListItem, nil)
|
||||
push_token(current_token, TokenType.Text, text[2:])
|
||||
current_token = current_token.parent
|
||||
continue
|
||||
}
|
||||
|
||||
// LAST-CASE SCENARIO: NORMAL TEXT
|
||||
|
||||
if current_token.parent == nil {
|
||||
|
||||
Reference in New Issue
Block a user