diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 21:38:06 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 21:38:06 +0200 |
| commit | dca42e27fe9c7d28c72bb6cb8e5cc4ec481572e8 (patch) | |
| tree | 5492f9c4b46b48e58d8002fd36deebd13c059291 /src/parser.zig | |
| parent | b0902c05ffc84d282e10a0179e041948d49fabf8 (diff) | |
feat(): support image
Diffstat (limited to 'src/parser.zig')
| -rw-r--r-- | src/parser.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/parser.zig b/src/parser.zig index 8c170e7..a5a49cd 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -10,7 +10,7 @@ const list = @import("list.zig"); pub const Error = error{ FeatureNotSupported, -} || Lexer.Error || paragraph.Error || title.Error || link.Error || Allocator.Error; +} || Lexer.Error || paragraph.Error || title.Error || link.Error || list.Error || link.ImageError || Allocator.Error; pub const Document = struct { arena: std.heap.ArenaAllocator, @@ -51,17 +51,21 @@ fn gen(parent: Allocator, l: *Lexer) Error!Document { var elements = try std.ArrayList(Element).initCapacity(alloc, 2); base: while (l.peek()) |it| { try elements.append(alloc, switch (it.kind) { - // block paragraph - .literal, .bold, .italic, .code, .link => try paragraph.parse(alloc, l), // other blocks .title => try title.parse(alloc, l), .list_ordored => try list.parseOrdored(alloc, l), .list_unordored => try list.parseUnordored(alloc, l), + .image => try link.parseImage(alloc, l), .weak_delimiter, .strong_delimiter => { l.consume(); continue :base; }, - else => return Error.FeatureNotSupported, + else => + // block paragraph + if (it.kind.isPar()) + try paragraph.parse(alloc, l) + else + return Error.FeatureNotSupported, }); } return .{ .root = try elements.toOwnedSlice(alloc), .arena = arena }; |
