From 2cc4aae1394b0c879dba4cf408f505b47b597bf1 Mon Sep 17 00:00:00 2001 From: "N0\\A" Date: Tue, 14 Jul 2026 19:28:28 +0200 Subject: [PATCH] More formatting --- README.tlm | 3 +++ src/html.odin | 21 +++++++++++++++++++++ src/main.odin | 6 ++++++ src/parser.odin | 5 +++++ 4 files changed, 35 insertions(+) diff --git a/README.tlm b/README.tlm index e029ddc..1b16d29 100644 --- a/README.tlm +++ b/README.tlm @@ -49,5 +49,8 @@ main :: proc() { --- +H_2_O_4_U is uranium peroxide +Here is some __underlined__ text + [&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 42196de..55b4aa4 100644 --- a/src/html.odin +++ b/src/html.odin @@ -213,6 +213,27 @@ print_html :: proc(token: ^Token) { case TokenType.HorizontalRule: fmt.print("
\n") + case TokenType.Underline: + fmt.print("") + for child in token.children { + print_html(child) + } + fmt.print("") + + case TokenType.Superscript: + fmt.print("") + for child in token.children { + print_html(child) + } + fmt.print("") + + case TokenType.Subscript: + fmt.print("") + for child in token.children { + print_html(child) + } + fmt.print("") + case TokenType.BreakLine: fmt.print("
\n") diff --git a/src/main.odin b/src/main.odin index 8c8b20e..b032076 100644 --- a/src/main.odin +++ b/src/main.odin @@ -65,6 +65,12 @@ print_token :: proc(token: ^Token, depth: int = 0) { type_str = "InlineCode" case TokenType.HorizontalRule: type_str = "HorizontalRule" + case TokenType.Underline: + type_str = "Underline" + case TokenType.Superscript: + type_str = "Superscript" + case TokenType.Subscript: + type_str = "Subscript" } value_str := "" diff --git a/src/parser.odin b/src/parser.odin index 569495b..cbb62d1 100644 --- a/src/parser.odin +++ b/src/parser.odin @@ -29,6 +29,9 @@ TokenType :: enum { CodeBlock, InlineCode, HorizontalRule, + Underline, + Superscript, + Subscript, } TokenValue :: union { @@ -258,6 +261,8 @@ pass_through_children :: proc(token: ^Token) { parse_inline_style(token, '*', []StyleToggle{{2, .Bold}, {1, .Italics}}) parse_inline_style(token, '~', []StyleToggle{{2, .Strikethrough}}) parse_inline_style(token, '-', []StyleToggle{{2, .Strikethrough}}) + parse_inline_style(token, '^', []StyleToggle{{1, .Superscript}}) + parse_inline_style(token, '_', []StyleToggle{{2, .Underline}, {1, .Subscript}}) } parse_inline_code :: proc(token: ^Token) {