diff options
Diffstat (limited to 'src/content.zig')
| -rw-r--r-- | src/content.zig | 15 |
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; +} |
