| ... | @@ -747,9 +747,7 @@ test { | ... | @@ -747,9 +747,7 @@ test { |
| 747 | const S = struct { | 747 | const S = struct { |
| 748 | name: []const u8, | 748 | name: []const u8, |
| 749 | | 749 | |
| 750 | pub fn format(s: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | 750 | pub fn nprint(s: @This(), writer: anytype) !void { |
| 751 | _ = fmt; | | |
| 752 | _ = options; | | |
| 753 | try writer.writeAll(s.name); | 751 | try writer.writeAll(s.name); |
| 754 | try writer.writeAll(".com"); | 752 | try writer.writeAll(".com"); |
| 755 | } | 753 | } |
| ... | @@ -776,38 +774,6 @@ test { | ... | @@ -776,38 +774,6 @@ test { |
| 776 | \\ | 774 | \\ |
| 777 | ); | 775 | ); |
| 778 | } | 776 | } |
| 779 | test { | | |
| 780 | const S = struct { | | |
| 781 | name: []const u8, | | |
| 782 | | | |
| 783 | pub fn toString(s: @This(), alloc: std.mem.Allocator) ![]const u8 { | | |
| 784 | return std.fmt.allocPrint(alloc, "{s}.com", .{s.name}); | | |
| 785 | } | | |
| 786 | }; | | |
| 787 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); | | |
| 788 | defer arena.deinit(); | | |
| 789 | const alloc = arena.allocator(); | | |
| 790 | var builder = std.ArrayList(u8).init(alloc); | | |
| 791 | defer builder.deinit(); | | |
| 792 | const doc = comptime pek.parse( | | |
| 793 | \\body( | | |
| 794 | \\ p("This host for this link is "a[href=("https://"{host}"/nektro/zig-pek")]("dynamic")".") | | |
| 795 | \\) | | |
| 796 | ); | | |
| 797 | try pek.compileInner( | | |
| 798 | alloc, | | |
| 799 | builder.writer(), | | |
| 800 | doc, | | |
| 801 | .{ .Ctx = @This(), .indent = 0, .doindent = true, .doindent2 = true }, | | |
| 802 | .{ .host = S{ .name = "github" } }, | | |
| 803 | ); | | |
| 804 | try expect(builder.items).toEqualString( | | |
| 805 | \\<body> | | |
| 806 | \\ <p>This host for this link is <a href="https://github.com/nektro/zig-pek">dynamic</a>.</p> | | |
| 807 | \\</body> | | |
| 808 | \\ | | |
| 809 | ); | | |
| 810 | } | | |
| 811 | | 777 | |
| 812 | // raw replacement | 778 | // raw replacement |
| 813 | test { | 779 | test { |