authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:52:09 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:52:09 -08:00
log49021184418ec124322660b4efb283481ec254b8
tree38e2c3239bbc40d8fca488a70ed8a2cac59893e8
parent33e66a5d2fb789b9e35ffe7298188dd2710aed5a

redo indentation


2 files changed, 66 insertions(+), 52 deletions(-)

src/lib.zig+32-20
...@@ -32,19 +32,29 @@ pub fn compile(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, co...@@ -32,19 +32,29 @@ pub fn compile(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, co
32 try do(alloc, writer, value, data, data, .{32 try do(alloc, writer, value, data, data, .{
33 .Ctx = Ctx,33 .Ctx = Ctx,
34 .indent = 0,34 .indent = 0,
35 .flag1 = false,35 .doindent = builtin.mode == .Debug,
36 .doindent2 = builtin.mode == .Debug,
36 });37 });
37 try writer.writeAll("\n");
38}38}
3939
40pub fn compileInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, comptime opts: DoOptions, data: anytype) !void {40pub fn compileInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, comptime opts: DoOptions, data: anytype) !void {
41 try do(alloc, writer, value, data, data, opts);41 try do(alloc, writer, value, data, data, opts);
42 try writer.writeAll("\n");
43}42}
4443
45pub const Writer = std.ArrayList(u8).Writer;44pub const Writer = std.ArrayList(u8).Writer;
4645
47fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, comptime opts: DoOptions) callconv(callconv_inline) anyerror!void {46fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, comptime opts: DoOptions) callconv(callconv_inline) anyerror!void {
47 comptime var skipindent = false;
48 if (value == .element and comptime std.mem.eql(u8, value.element.name, "pre")) skipindent = true;
49 return doInner(alloc, writer, value, data, ctx, .{
50 .Ctx = opts.Ctx,
51 .indent = opts.indent,
52 .doindent = opts.doindent and !skipindent,
53 .doindent2 = opts.doindent,
54 .escaped = opts.escaped,
55 });
56}
57fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, comptime opts: DoOptions) callconv(callconv_inline) anyerror!void {
48 switch (comptime value) {58 switch (comptime value) {
49 .element => |v| {59 .element => |v| {
50 const hastext = comptime for (v.children) |x| {60 const hastext = comptime for (v.children) |x| {
...@@ -53,14 +63,15 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -53,14 +63,15 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
53 .element, .attr, .block, .body => {},63 .element, .attr, .block, .body => {},
54 }64 }
55 } else false;65 } else false;
66 _ = hastext;
5667
57 if (opts.flag1) for (0..opts.indent) |_| try writer.writeAll(" ");68 if (opts.doindent2) for (0..opts.indent) |_| try writer.writeAll(" ");
58 try writer.writeAll("<");69 try writer.writeAll("<");
59 try writer.writeAll(v.name);70 try writer.writeAll(v.name);
6071
61 inline for (v.attrs) |it| {72 inline for (v.attrs) |it| {
62 switch (comptime it.value) {73 switch (comptime it.value) {
63 .string => try writer.print(" {s}=\"{}\"", .{ it.key, std.zig.fmtEscapes(it.value.string[1 .. it.value.string.len - 1]) }),74 .string => try writer.print(" {s}={s}", .{ it.key, it.value.string }),
64 .body => {75 .body => {
65 try writer.print(" {s}=\"", .{it.key});76 try writer.print(" {s}=\"", .{it.key});
66 inline for (it.value.body) |bval| try do(alloc, writer, bval, data, ctx, opts);77 inline for (it.value.body) |bval| try do(alloc, writer, bval, data, ctx, opts);
...@@ -71,24 +82,27 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -71,24 +82,27 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
7182
72 if (v.children.len == 0) {83 if (v.children.len == 0) {
73 if (contains(std.meta.fieldNames(HtmlVoidElements), v.name)) {84 if (contains(std.meta.fieldNames(HtmlVoidElements), v.name)) {
74 try writer.writeAll(" />\n");85 try writer.writeAll(" />");
86 if (opts.doindent2) try writer.writeAll("\n");
75 } else {87 } else {
76 try writer.print("></{s}>\n", .{v.name});88 try writer.print("></{s}>", .{v.name});
89 if (opts.doindent2) try writer.writeAll("\n");
77 }90 }
78 } else {91 } else {
92 const shouldindent = opts.doindent and v.children[0] != .string and v.children[0] != .replacement;
79 try writer.writeAll(">");93 try writer.writeAll(">");
8094 if (shouldindent) try writer.writeAll("\n");
81 if (!hastext) try writer.writeAll("\n");
82 inline for (v.children) |it| {95 inline for (v.children) |it| {
83 try do(alloc, writer, it, data, ctx, .{96 try do(alloc, writer, it, data, ctx, .{
84 .Ctx = opts.Ctx,97 .Ctx = opts.Ctx,
85 .indent = opts.indent + 1,98 .indent = opts.indent + 1,
86 .flag1 = !hastext,99 .doindent = shouldindent,
100 .doindent2 = opts.doindent2,
87 });101 });
88 }102 }
89 if (!hastext) for (0..opts.indent) |_| try writer.writeAll(" ");103 if (shouldindent) for (0..opts.indent) |_| try writer.writeAll(" ");
90 try writer.print("</{s}>", .{v.name});104 try writer.print("</{s}>", .{v.name});
91 if (opts.flag1) try writer.writeAll("\n");105 if (opts.doindent2) try writer.writeAll("\n");
92 }106 }
93 },107 },
94 .string => |v| {108 .string => |v| {
...@@ -253,13 +267,10 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -253,13 +267,10 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
253 }267 }
254 },268 },
255 .function => |v| {269 .function => |v| {
256 var arena = std.heap.ArenaAllocator.init(alloc);
257 defer arena.deinit();
258
259 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {270 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {
260 const func = @field(opts.Ctx, "pek_" ++ v.name);271 const func = @field(opts.Ctx, "pek_" ++ v.name);
261 var list = std.ArrayList(u8).init(arena.allocator());272 var list = std.ArrayList(u8).init(alloc);
262 errdefer list.deinit();273 defer list.deinit();
263 var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined;274 var args: std.meta.ArgsTuple(@TypeOf(func)) = undefined;
264 comptime std.debug.assert(args.len - 2 == v.args.len);275 comptime std.debug.assert(args.len - 2 == v.args.len);
265 args.@"0" = alloc;276 args.@"0" = alloc;
...@@ -274,8 +285,8 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -274,8 +285,8 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
274 }285 }
275 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {286 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {
276 const func = @field(opts.Ctx, "pek__" ++ v.name);287 const func = @field(opts.Ctx, "pek__" ++ v.name);
277 var list = std.ArrayList(u8).init(arena.allocator());288 var list = std.ArrayList(u8).init(alloc);
278 errdefer list.deinit();289 defer list.deinit();
279 const AT = std.meta.ArgsTuple(@TypeOf(func));290 const AT = std.meta.ArgsTuple(@TypeOf(func));
280 const ATT = std.meta.fieldInfo(AT, .@"3").type;291 const ATT = std.meta.fieldInfo(AT, .@"3").type;
281 if (v.args.len != std.meta.fields(ATT).len) @compileError(std.fmt.comptimePrint("expected:{d} - actual:{d}", .{ std.meta.fields(ATT).len, v.args.len }));292 if (v.args.len != std.meta.fields(ATT).len) @compileError(std.fmt.comptimePrint("expected:{d} - actual:{d}", .{ std.meta.fields(ATT).len, v.args.len }));
...@@ -310,7 +321,8 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -310,7 +321,8 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
310pub const DoOptions = struct {321pub const DoOptions = struct {
311 Ctx: type,322 Ctx: type,
312 indent: usize,323 indent: usize,
313 flag1: bool,324 doindent: bool,
325 doindent2: bool,
314 escaped: bool = true,326 escaped: bool = true,
315};327};
316328
test.zig+34-32
...@@ -65,7 +65,7 @@ test "fragment" {...@@ -65,7 +65,7 @@ test "fragment" {
65 alloc,65 alloc,
66 builder.writer(),66 builder.writer(),
67 doc,67 doc,
68 .{ .Ctx = @This(), .indent = 0, .flag1 = false },68 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
69 .{},69 .{},
70 );70 );
71 try expect(builder.items).toEqualString(71 try expect(builder.items).toEqualString(
...@@ -98,7 +98,7 @@ test "if: basic" {...@@ -98,7 +98,7 @@ test "if: basic" {
98 alloc,98 alloc,
99 builder.writer(),99 builder.writer(),
100 doc,100 doc,
101 .{ .Ctx = @This(), .indent = 0, .flag1 = false },101 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
102 .{ .foo = false, .bar = true },102 .{ .foo = false, .bar = true },
103 );103 );
104 try expect(builder.items).toEqualString(104 try expect(builder.items).toEqualString(
...@@ -129,7 +129,7 @@ test "if else + field access" {...@@ -129,7 +129,7 @@ test "if else + field access" {
129 alloc,129 alloc,
130 builder.writer(),130 builder.writer(),
131 doc,131 doc,
132 .{ .Ctx = @This(), .indent = 0, .flag1 = false },132 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
133 .{ .bar = .{ .qux = false } },133 .{ .bar = .{ .qux = false } },
134 );134 );
135 try expect(builder.items).toEqualString(135 try expect(builder.items).toEqualString(
...@@ -158,7 +158,7 @@ test {...@@ -158,7 +158,7 @@ test {
158 alloc,158 alloc,
159 builder.writer(),159 builder.writer(),
160 doc,160 doc,
161 .{ .Ctx = @This(), .indent = 0, .flag1 = false },161 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
162 .{ .bar = true },162 .{ .bar = true },
163 );163 );
164 try expect(builder.items).toEqualString(164 try expect(builder.items).toEqualString(
...@@ -185,7 +185,7 @@ test {...@@ -185,7 +185,7 @@ test {
185 alloc,185 alloc,
186 builder.writer(),186 builder.writer(),
187 doc,187 doc,
188 .{ .Ctx = @This(), .indent = 0, .flag1 = false },188 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
189 .{ .bar = false },189 .{ .bar = false },
190 );190 );
191 try expect(builder.items).toEqualString(191 try expect(builder.items).toEqualString(
...@@ -214,7 +214,7 @@ test { // bool...@@ -214,7 +214,7 @@ test { // bool
214 alloc,214 alloc,
215 builder.writer(),215 builder.writer(),
216 doc,216 doc,
217 .{ .Ctx = @This(), .indent = 0, .flag1 = false },217 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
218 .{ .bar = true },218 .{ .bar = true },
219 );219 );
220 try expect(builder.items).toEqualString(220 try expect(builder.items).toEqualString(
...@@ -241,7 +241,7 @@ test { // bool false...@@ -241,7 +241,7 @@ test { // bool false
241 alloc,241 alloc,
242 builder.writer(),242 builder.writer(),
243 doc,243 doc,
244 .{ .Ctx = @This(), .indent = 0, .flag1 = false },244 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
245 .{ .bar = false },245 .{ .bar = false },
246 );246 );
247 try expect(builder.items).toEqualString(247 try expect(builder.items).toEqualString(
...@@ -268,7 +268,7 @@ test { // string...@@ -268,7 +268,7 @@ test { // string
268 alloc,268 alloc,
269 builder.writer(),269 builder.writer(),
270 doc,270 doc,
271 .{ .Ctx = @This(), .indent = 0, .flag1 = false },271 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
272 .{ .bar = @as([]const u8, "foo") },272 .{ .bar = @as([]const u8, "foo") },
273 );273 );
274 try expect(builder.items).toEqualString(274 try expect(builder.items).toEqualString(
...@@ -295,7 +295,7 @@ test { // string false...@@ -295,7 +295,7 @@ test { // string false
295 alloc,295 alloc,
296 builder.writer(),296 builder.writer(),
297 doc,297 doc,
298 .{ .Ctx = @This(), .indent = 0, .flag1 = false },298 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
299 .{ .bar = @as([]const u8, "qux") },299 .{ .bar = @as([]const u8, "qux") },
300 );300 );
301 try expect(builder.items).toEqualString(301 try expect(builder.items).toEqualString(
...@@ -322,7 +322,7 @@ test { // enum...@@ -322,7 +322,7 @@ test { // enum
322 alloc,322 alloc,
323 builder.writer(),323 builder.writer(),
324 doc,324 doc,
325 .{ .Ctx = @This(), .indent = 0, .flag1 = false },325 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
326 .{ .bar = @as(enum { foo, bar, qux }, .foo) },326 .{ .bar = @as(enum { foo, bar, qux }, .foo) },
327 );327 );
328 try expect(builder.items).toEqualString(328 try expect(builder.items).toEqualString(
...@@ -349,7 +349,7 @@ test { // enum false...@@ -349,7 +349,7 @@ test { // enum false
349 alloc,349 alloc,
350 builder.writer(),350 builder.writer(),
351 doc,351 doc,
352 .{ .Ctx = @This(), .indent = 0, .flag1 = false },352 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
353 .{ .bar = @as(enum { foo, bar, qux }, .qux) },353 .{ .bar = @as(enum { foo, bar, qux }, .qux) },
354 );354 );
355 try expect(builder.items).toEqualString(355 try expect(builder.items).toEqualString(
...@@ -378,7 +378,7 @@ test { // bool...@@ -378,7 +378,7 @@ test { // bool
378 alloc,378 alloc,
379 builder.writer(),379 builder.writer(),
380 doc,380 doc,
381 .{ .Ctx = @This(), .indent = 0, .flag1 = false },381 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
382 .{ .bar = false },382 .{ .bar = false },
383 );383 );
384 try expect(builder.items).toEqualString(384 try expect(builder.items).toEqualString(
...@@ -405,7 +405,7 @@ test { // bool false...@@ -405,7 +405,7 @@ test { // bool false
405 alloc,405 alloc,
406 builder.writer(),406 builder.writer(),
407 doc,407 doc,
408 .{ .Ctx = @This(), .indent = 0, .flag1 = false },408 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
409 .{ .bar = true },409 .{ .bar = true },
410 );410 );
411 try expect(builder.items).toEqualString(411 try expect(builder.items).toEqualString(
...@@ -432,7 +432,7 @@ test { // string...@@ -432,7 +432,7 @@ test { // string
432 alloc,432 alloc,
433 builder.writer(),433 builder.writer(),
434 doc,434 doc,
435 .{ .Ctx = @This(), .indent = 0, .flag1 = false },435 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
436 .{ .bar = @as([]const u8, "qux") },436 .{ .bar = @as([]const u8, "qux") },
437 );437 );
438 try expect(builder.items).toEqualString(438 try expect(builder.items).toEqualString(
...@@ -459,7 +459,7 @@ test { // string false...@@ -459,7 +459,7 @@ test { // string false
459 alloc,459 alloc,
460 builder.writer(),460 builder.writer(),
461 doc,461 doc,
462 .{ .Ctx = @This(), .indent = 0, .flag1 = false },462 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
463 .{ .bar = @as([]const u8, "foo") },463 .{ .bar = @as([]const u8, "foo") },
464 );464 );
465 try expect(builder.items).toEqualString(465 try expect(builder.items).toEqualString(
...@@ -486,7 +486,7 @@ test { // enum...@@ -486,7 +486,7 @@ test { // enum
486 alloc,486 alloc,
487 builder.writer(),487 builder.writer(),
488 doc,488 doc,
489 .{ .Ctx = @This(), .indent = 0, .flag1 = false },489 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
490 .{ .bar = @as(enum { foo, bar, qux }, .qux) },490 .{ .bar = @as(enum { foo, bar, qux }, .qux) },
491 );491 );
492 try expect(builder.items).toEqualString(492 try expect(builder.items).toEqualString(
...@@ -513,7 +513,7 @@ test { // enum false...@@ -513,7 +513,7 @@ test { // enum false
513 alloc,513 alloc,
514 builder.writer(),514 builder.writer(),
515 doc,515 doc,
516 .{ .Ctx = @This(), .indent = 0, .flag1 = false },516 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
517 .{ .bar = @as(enum { foo, bar, qux }, .foo) },517 .{ .bar = @as(enum { foo, bar, qux }, .foo) },
518 );518 );
519 try expect(builder.items).toEqualString(519 try expect(builder.items).toEqualString(
...@@ -538,7 +538,7 @@ test {...@@ -538,7 +538,7 @@ test {
538 alloc,538 alloc,
539 builder.writer(),539 builder.writer(),
540 doc,540 doc,
541 .{ .Ctx = @This(), .indent = 0, .flag1 = false },541 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
542 .{ .text = @as([]const u8, "dynamic") },542 .{ .text = @as([]const u8, "dynamic") },
543 );543 );
544 try expect(builder.items).toEqualString(544 try expect(builder.items).toEqualString(
...@@ -561,7 +561,7 @@ test {...@@ -561,7 +561,7 @@ test {
561 alloc,561 alloc,
562 builder.writer(),562 builder.writer(),
563 doc,563 doc,
564 .{ .Ctx = @This(), .indent = 0, .flag1 = false },564 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
565 .{ .url = @as([]const u8, "https://github.com/nektro/zig-pek") },565 .{ .url = @as([]const u8, "https://github.com/nektro/zig-pek") },
566 );566 );
567 try expect(builder.items).toEqualString(567 try expect(builder.items).toEqualString(
...@@ -584,7 +584,7 @@ test {...@@ -584,7 +584,7 @@ test {
584 alloc,584 alloc,
585 builder.writer(),585 builder.writer(),
586 doc,586 doc,
587 .{ .Ctx = @This(), .indent = 0, .flag1 = false },587 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
588 .{ .host = @as([]const u8, "github.com") },588 .{ .host = @as([]const u8, "github.com") },
589 );589 );
590 try expect(builder.items).toEqualString(590 try expect(builder.items).toEqualString(
...@@ -607,7 +607,7 @@ test {...@@ -607,7 +607,7 @@ test {
607 alloc,607 alloc,
608 builder.writer(),608 builder.writer(),
609 doc,609 doc,
610 .{ .Ctx = @This(), .indent = 0, .flag1 = false },610 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
611 .{ .host = "github.com".* },611 .{ .host = "github.com".* },
612 );612 );
613 try expect(builder.items).toEqualString(613 try expect(builder.items).toEqualString(
...@@ -642,7 +642,7 @@ test {...@@ -642,7 +642,7 @@ test {
642 alloc,642 alloc,
643 builder.writer(),643 builder.writer(),
644 doc,644 doc,
645 .{ .Ctx = @This(), .indent = 0, .flag1 = false },645 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
646 .{ .host = S{ .name = "github" } },646 .{ .host = S{ .name = "github" } },
647 );647 );
648 try expect(builder.items).toEqualString(648 try expect(builder.items).toEqualString(
...@@ -674,7 +674,7 @@ test {...@@ -674,7 +674,7 @@ test {
674 alloc,674 alloc,
675 builder.writer(),675 builder.writer(),
676 doc,676 doc,
677 .{ .Ctx = @This(), .indent = 0, .flag1 = false },677 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
678 .{ .host = S{ .name = "github" } },678 .{ .host = S{ .name = "github" } },
679 );679 );
680 try expect(builder.items).toEqualString(680 try expect(builder.items).toEqualString(
...@@ -699,7 +699,7 @@ test {...@@ -699,7 +699,7 @@ test {
699 alloc,699 alloc,
700 builder.writer(),700 builder.writer(),
701 doc,701 doc,
702 .{ .Ctx = @This(), .indent = 0, .flag1 = false },702 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
703 .{ .url = "https://github.com/nektro/zig-pek".* },703 .{ .url = "https://github.com/nektro/zig-pek".* },
704 );704 );
705 try expect(builder.items).toEqualString(705 try expect(builder.items).toEqualString(
...@@ -722,7 +722,7 @@ test {...@@ -722,7 +722,7 @@ test {
722 alloc,722 alloc,
723 builder.writer(),723 builder.writer(),
724 doc,724 doc,
725 .{ .Ctx = @This(), .indent = 0, .flag1 = false },725 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
726 .{ .foo = "contain HTML such as <button>this</button> as an escape hatch when you know content is safe".* },726 .{ .foo = "contain HTML such as <button>this</button> as an escape hatch when you know content is safe".* },
727 );727 );
728 try expect(builder.items).toEqualString(728 try expect(builder.items).toEqualString(
...@@ -770,16 +770,18 @@ test {...@@ -770,16 +770,18 @@ test {
770 alloc,770 alloc,
771 builder.writer(),771 builder.writer(),
772 doc,772 doc,
773 .{ .Ctx = C, .indent = 0, .flag1 = false },773 .{ .Ctx = C, .indent = 0, .doindent = true, .doindent2 = true },
774 .{ .prev = person },774 .{ .prev = person },
775 );775 );
776 try expect(builder.items).toEqualString(776 try expect(builder.items).toEqualString(
777 \\<body>777 \\<body>
778 \\ <form><label>778 \\ <form>
779 \\ <label>
779 \\ <div>Name</div>780 \\ <div>Name</div>
780 \\ <textarea type="text" required="" name="name" placeholder="">meghan</textarea>781 \\ <textarea type="text" required="" name="name" placeholder="">meghan</textarea>
781 \\ </label>782 \\ </label>
782 \\<button>Submit ▶</button></form>783 \\ <button>Submit ▶</button>
784 \\ </form>
783 \\</body>785 \\</body>
784 \\786 \\
785 );787 );
...@@ -816,7 +818,7 @@ test {...@@ -816,7 +818,7 @@ test {
816 alloc,818 alloc,
817 builder.writer(),819 builder.writer(),
818 doc,820 doc,
819 .{ .Ctx = C, .indent = 0, .flag1 = false },821 .{ .Ctx = C, .indent = 0, .doindent = true, .doindent2 = true },
820 .{ .user = person },822 .{ .user = person },
821 );823 );
822 try expect(builder.items).toEqualString(824 try expect(builder.items).toEqualString(
...@@ -856,7 +858,7 @@ test {...@@ -856,7 +858,7 @@ test {
856 alloc,858 alloc,
857 builder.writer(),859 builder.writer(),
858 doc,860 doc,
859 .{ .Ctx = C, .indent = 0, .flag1 = false },861 .{ .Ctx = C, .indent = 0, .doindent = true, .doindent2 = true },
860 .{ .user = person },862 .{ .user = person },
861 );863 );
862 try expect(builder.items).toEqualString(864 try expect(builder.items).toEqualString(
...@@ -893,7 +895,7 @@ test {...@@ -893,7 +895,7 @@ test {
893 alloc,895 alloc,
894 builder.writer(),896 builder.writer(),
895 doc,897 doc,
896 .{ .Ctx = @This(), .indent = 0, .flag1 = false },898 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
897 .{ .states = &states },899 .{ .states = &states },
898 );900 );
899 try expect(builder.items).toEqualString(901 try expect(builder.items).toEqualString(
...@@ -932,7 +934,7 @@ test {...@@ -932,7 +934,7 @@ test {
932 alloc,934 alloc,
933 builder.writer(),935 builder.writer(),
934 doc,936 doc,
935 .{ .Ctx = @This(), .indent = 0, .flag1 = false },937 .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true },
936 .{ .abbrs = states.items.abbr, .names = states.items.name },938 .{ .abbrs = states.items.abbr, .names = states.items.name },
937 );939 );
938 try expect(builder.items).toEqualString(940 try expect(builder.items).toEqualString(