Skip to content

Commit 1d8e87a

Browse files
committed
fix wrong vertical indentation for void elements
closes #40
1 parent e561df3 commit 1d8e87a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/html/Ast.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,14 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
714714

715715
// if (std.mem.eql(u8, name, "path")) @breakpoint();
716716

717+
const extra: u32 = switch (current.kind) {
718+
.doctype,
719+
.element_void,
720+
.element_self_closing,
721+
=> 1,
722+
else => 0,
723+
};
724+
717725
while (tt.next(src[0..current.open.end])) |maybe_attr| {
718726
log.debug("tt: {s}", .{@tagName(maybe_attr)});
719727
log.debug("tt: {any}", .{maybe_attr});
@@ -736,7 +744,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
736744
.attr => |attr| {
737745
if (vertical) {
738746
try w.print("\n", .{});
739-
for (0..indentation) |_| {
747+
for (0..indentation + extra) |_| {
740748
try w.print(" ", .{});
741749
}
742750
} else {

0 commit comments

Comments
 (0)