Skip to content

Commit

Permalink
fix wrong vertical indentation for void elements
Browse files Browse the repository at this point in the history
closes #40
  • Loading branch information
kristoff-it committed Oct 30, 2024
1 parent e561df3 commit 1d8e87a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/html/Ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,14 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {

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

const extra: u32 = switch (current.kind) {
.doctype,
.element_void,
.element_self_closing,
=> 1,
else => 0,
};

while (tt.next(src[0..current.open.end])) |maybe_attr| {
log.debug("tt: {s}", .{@tagName(maybe_attr)});
log.debug("tt: {any}", .{maybe_attr});
Expand All @@ -736,7 +744,7 @@ pub fn render(ast: Ast, src: []const u8, w: anytype) !void {
.attr => |attr| {
if (vertical) {
try w.print("\n", .{});
for (0..indentation) |_| {
for (0..indentation + extra) |_| {
try w.print(" ", .{});
}
} else {
Expand Down

0 comments on commit 1d8e87a

Please sign in to comment.