diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 21:11:49 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 21:11:49 +0200 |
| commit | 80ca399d821cd6380c37e507f2b1b13007174221 (patch) | |
| tree | 4c72beda650f56614e26ee96e076882295d7ad5d | |
| parent | a75d03583c0691b1830122979d44737e574f27c7 (diff) | |
refactor(eval): generate figure in ast and not in eval for quote
| -rw-r--r-- | src/eval/blocks.zig | 9 | ||||
| -rw-r--r-- | src/quote.zig | 5 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/eval/blocks.zig b/src/eval/blocks.zig index 9f96c3d..a270ec9 100644 --- a/src/eval/blocks.zig +++ b/src/eval/blocks.zig @@ -147,7 +147,6 @@ pub const Callout = struct { pub const Quote = struct { content: Element, - attribution: ?Element = null, node: Node = .{ .ptr = undefined, .vtable = .{ .element = fromNode }, @@ -178,10 +177,8 @@ pub const Quote = struct { fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML { const self: *Self = @ptrCast(@alignCast(context)); - const quote = try Element.Simple("blockquote").init(alloc); - quote.content = self.content; - var el = try Figure.init(alloc, quote.element()); - el.caption = self.attribution; - return try el.element().html(alloc); + const quote = try HTML.Content.init(alloc, "blockquote"); + quote.content = try self.content.html(alloc); + return quote.element(); } }; diff --git a/src/quote.zig b/src/quote.zig index 8c24c7e..5456d5b 100644 --- a/src/quote.zig +++ b/src/quote.zig @@ -26,7 +26,8 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { .strong_delimiter => break, else => root.append(try paragraph.parseLine(alloc, l)), }; - const el = try Element.Quote.init(alloc, root.element()); + const quote = try Element.Quote.init(alloc, root.element()); + const el = try Element.Figure.init(alloc, quote.element()); const v = l.peek() orelse return el.element(); if (v.kind == .strong_delimiter) { l.consume(); @@ -34,7 +35,7 @@ pub fn parse(alloc: Allocator, l: *Lexer) Error!Element { } const attr = try paragraph.parse(alloc, l); const p_el: *Element.paragraph.Block = @ptrCast(@alignCast(attr.ptr)); - el.attribution = (try p_el.toRoot(alloc)).element(); + el.caption = (try p_el.toRoot(alloc)).element(); return el.element(); } |
