diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 23:10:17 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 23:17:26 +0200 |
| commit | de948492e8b38a79d5db9c506c1b7b82e86c6b12 (patch) | |
| tree | 122e4c004d37193c64d6b8b89d9a252f7e237cfa /src/paragraph.zig | |
| parent | ae6ee68d6f4ef79fef609b4d09b543fc06326e95 (diff) | |
feat(): support code block
Diffstat (limited to 'src/paragraph.zig')
| -rw-r--r-- | src/paragraph.zig | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/src/paragraph.zig b/src/paragraph.zig index c2e0175..b50b2ec 100644 --- a/src/paragraph.zig +++ b/src/paragraph.zig @@ -16,39 +16,35 @@ pub const Error = content.Error || link.Error || Allocator.Error; pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { var el = try Paragraph.Block.init(alloc); errdefer el.deinit(alloc); - while (l.peek()) |next| { - switch (next.kind) { - .strong_delimiter => return el.element(), - .weak_delimiter => { - l.consume(); - const future = l.peek() orelse return el.element(); - if (!future.kind.isPar()) return el.element(); - try el.content.append(alloc, (try Element.Literal.init(alloc, " ")).element()); - }, - else => try el.content.append(alloc, try parseLine(alloc, l)), - } - } + while (l.peek()) |next| switch (next.kind) { + .strong_delimiter => return el.element(), + .weak_delimiter => { + l.consume(); + const future = l.peek() orelse return el.element(); + if (!future.kind.isPar()) return el.element(); + try el.content.append(alloc, (try Element.Literal.init(alloc, " ")).element()); + }, + else => try el.content.append(alloc, try parseLine(alloc, l)), + }; return el.element(); } pub fn parseLine(alloc: Allocator, l: *Lexer) Error!Element { var line = try Element.Empty.init(alloc); errdefer line.deinit(alloc); - while (l.peek()) |next| { - switch (next.kind) { - .weak_delimiter, .strong_delimiter => return line.element(), - .link => { - var el = try link.parse(alloc, l); - errdefer el.deinit(alloc); - try line.content.append(alloc, el); - }, - else => { - var el = try content.parse(alloc, l); - errdefer el.deinit(alloc); - try line.content.append(alloc, el); - }, - } - } + while (l.peek()) |next| switch (next.kind) { + .weak_delimiter, .strong_delimiter => return line.element(), + .link => { + var el = try link.parse(alloc, l); + errdefer el.deinit(alloc); + try line.content.append(alloc, el); + }, + else => { + var el = try content.parse(alloc, l); + errdefer el.deinit(alloc); + try line.content.append(alloc, el); + }, + }; return line.element(); } |
