aboutsummaryrefslogtreecommitdiff
path: root/src/content.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-29 19:55:57 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-29 19:55:57 +0200
commitafd538d6af0baf8a1861ff2cdef881edbfb57000 (patch)
treedb41d566c318163cb41916defd7cd274b92a9a43 /src/content.zig
parent0535fa152ae990a28d0b7b9a59e96911074118b8 (diff)
feat(): support math content
Diffstat (limited to 'src/content.zig')
-rw-r--r--src/content.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/content.zig b/src/content.zig
index fe1b844..067c44f 100644
--- a/src/content.zig
+++ b/src/content.zig
@@ -22,6 +22,7 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element {
.bold => content.append(try parseModifier(alloc, l, .bold, "b")),
.italic => content.append(try parseModifier(alloc, l, .italic, "em")),
.code => content.append(try parseModifier(alloc, l, .code, "code")),
+ .math => content.append(try parseMath(alloc, l)),
else => return Error.IllegalPlacement,
}
return content.element();
@@ -42,3 +43,17 @@ fn parseModifier(alloc: Allocator, l: *Lexer, knd: Token.Kind, comptime tag: []c
}
return Error.ModifierNotClosed;
}
+
+fn parseMath(alloc: Allocator, l: *Lexer) Error!Element {
+ const el = try Element.Math.Content.init(alloc);
+ var acc = try std.ArrayList(u8).initCapacity(alloc, 2);
+ while (l.next()) |it| {
+ if (it.kind == .math) {
+ el.content = try acc.toOwnedSlice(alloc);
+ return el.element();
+ }
+ if (it.kind.isDelimiter()) return Error.ModifierNotClosed;
+ try acc.appendSlice(alloc, it.content);
+ }
+ return Error.ModifierNotClosed;
+}