From b4f5285a998a8d6534347fae04ab831c73a47d53 Mon Sep 17 00:00:00 2001 From: "N0\\A" Date: Tue, 14 Jul 2026 13:41:51 +0200 Subject: [PATCH] Unordered lists --- src/main.odin | 6 ++++++ src/parser.odin | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main.odin b/src/main.odin index 2b639ba..f386fd4 100644 --- a/src/main.odin +++ b/src/main.odin @@ -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 := "" diff --git a/src/parser.odin b/src/parser.odin index 4b09759..628b0d8 100644 --- a/src/parser.odin +++ b/src/parser.odin @@ -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 {