diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 20:52:56 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-28 20:52:56 +0200 |
| commit | c6e771fff0515d3a8e0cbc928c103b6c86f22c0f (patch) | |
| tree | 6b3130e33680d5beb1e6ab9bba818352e83657dc /src/eval/blocks.zig | |
| parent | 7b1b855ed68b4fc72d01de170226ea0fcc74a512 (diff) | |
feat(): support quote
Diffstat (limited to 'src/eval/blocks.zig')
| -rw-r--r-- | src/eval/blocks.zig | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/eval/blocks.zig b/src/eval/blocks.zig index cbb95b1..32f2de3 100644 --- a/src/eval/blocks.zig +++ b/src/eval/blocks.zig @@ -138,3 +138,44 @@ pub const Callout = struct { return el.element(); } }; + +pub const Quote = struct { + content: Element, + attribution: ?Element = null, + node: Node = .{ + .ptr = undefined, + .vtable = .{ .element = fromNode }, + }, + + const Self = @This(); + + pub fn init(alloc: Allocator, content: Element) !*Self { + const v = try alloc.create(Self); + v.* = .{ .content = content }; + v.node.ptr = v; + return v; + } + + pub fn element(self: *Self) Element { + return .{ .ptr = self, .vtable = .{ .html = html, .node = getNode } }; + } + + fn getNode(context: *anyopaque) *Node { + const self: *Self = @ptrCast(@alignCast(context)); + return &self.node; + } + + fn fromNode(context: *anyopaque) Element { + const self: *Self = @ptrCast(@alignCast(context)); + return self.element(); + } + + 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); + } +}; |
