diff options
Diffstat (limited to 'src/eval/Image.zig')
| -rw-r--r-- | src/eval/Image.zig | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/eval/Image.zig b/src/eval/Image.zig index 7991d69..740d876 100644 --- a/src/eval/Image.zig +++ b/src/eval/Image.zig @@ -7,7 +7,6 @@ const Self = @This(); src: []const u8, alt: ?[]const u8 = null, -source: ?Element = null, pub fn init(alloc: Allocator, src: []const u8) !*Self { const v = try alloc.create(Self); @@ -27,7 +26,6 @@ pub fn deinit(self: *Self, alloc: Allocator) void { fn destroy(context: *anyopaque, alloc: Allocator) void { const self: *Self = @ptrCast(@alignCast(context)); - if (self.source) |it| it.deinit(alloc); alloc.destroy(self); } @@ -38,16 +36,7 @@ fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML { errdefer img.deinit(); try img.setAttribute("src", self.src); if (self.alt) |it| try img.setAttribute("alt", it); - var el = try HTML.init(alloc, .content, "figure"); - errdefer el.deinit(); - try el.appendContent(img); - - const source = self.source orelse return el; - var caption = try HTML.init(alloc, .content, "figcaption"); - errdefer caption.deinit(); - try caption.appendContent(try source.html(alloc)); - try el.appendContent(caption); - return el; + return img; } test "html" { @@ -59,17 +48,10 @@ test "html" { defer img.deinit(alloc); const h = try img.element().renderHTML(alloc); defer alloc.free(h); - try expect(eql(u8, h, "<figure><img src=\"foo\"></figure>")); + try expect(eql(u8, h, "<img src=\"foo\">")); img.alt = "bar"; 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>")); + try expect(eql(u8, h2, "<img src=\"foo\" alt=\"bar\">")); } |
