aboutsummaryrefslogtreecommitdiff
path: root/src/eval/Image.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-26 22:07:03 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-26 22:07:03 +0200
commit1ce415538f202bf1319ebb0ff6e76aa54f983343 (patch)
treede7febaf453855229581fdc2dbcc92fd2bd1bed3 /src/eval/Image.zig
parentdca42e27fe9c7d28c72bb6cb8e5cc4ec481572e8 (diff)
perf(parse): reduce realloc for figcaptions
Diffstat (limited to 'src/eval/Image.zig')
-rw-r--r--src/eval/Image.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/eval/Image.zig b/src/eval/Image.zig
index 771c8ee..7991d69 100644
--- a/src/eval/Image.zig
+++ b/src/eval/Image.zig
@@ -45,7 +45,7 @@ fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML {
const source = self.source orelse return el;
var caption = try HTML.init(alloc, .content, "figcaption");
errdefer caption.deinit();
- try caption.content.append(alloc, try source.html(alloc));
+ try caption.appendContent(try source.html(alloc));
try el.appendContent(caption);
return el;
}
@@ -65,4 +65,11 @@ test "html" {
const h2 = try img.element().renderHTML(alloc);
defer alloc.free(h2);
try expect(eql(u8, h2, "<figure><img src=\"foo\" alt=\"bar\"></figure>"));
+
+ const in = try Element.Empty.init(alloc);
+ try in.content.append(alloc, (try Element.Literal.init(alloc, "caption")).element());
+ img.source = in.element();
+ const h3 = try img.element().renderHTML(alloc);
+ defer alloc.free(h3);
+ try expect(eql(u8, h3, "<figure><img src=\"foo\" alt=\"bar\"><figcaption>caption</figcaption></figure>"));
}