aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-26 22:29:40 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-26 22:29:40 +0200
commitae6ee68d6f4ef79fef609b4d09b543fc06326e95 (patch)
tree04f7059b0ed5bb1323280ce9c910f8f154af5eac /src/link.zig
parent1ce415538f202bf1319ebb0ff6e76aa54f983343 (diff)
refactor(eval): generalize figure
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/link.zig b/src/link.zig
index 3333e76..9bfbde5 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -70,9 +70,11 @@ pub fn parseImage(alloc: Allocator, l: *Lexer) ImageError!Element {
const src = it.content;
it = l.next() orelse return ImageError.InvalidImage;
if (!it.equals(.link, ")")) return ImageError.InvalidImage;
- const el = try Element.Image.init(alloc, src);
+ const img = try Element.Image.init(alloc, src);
+ errdefer img.deinit(alloc);
+ img.alt = alt;
+ const el = try Element.Figure.init(alloc, img.element());
errdefer el.deinit(alloc);
- el.alt = alt;
it = l.peek() orelse return el.element();
switch (it.kind) {
.strong_delimiter => return el.element(),
@@ -82,7 +84,7 @@ pub fn parseImage(alloc: Allocator, l: *Lexer) ImageError!Element {
const p = try paragraph.parse(alloc, l);
errdefer p.deinit(alloc);
const p_el: *Element.paragraph.Block = @ptrCast(@alignCast(p.ptr));
- el.source = (try p_el.toEmpty(alloc)).element();
+ el.caption = (try p_el.toEmpty(alloc)).element();
return el.element();
}