From 109b73a3936c90aa89cd12c60aacf51439d31370 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 10 Sep 2025 13:38:16 +0200 Subject: use rbl for running pandoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/gen.zig | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/gen.zig') diff --git a/src/gen.zig b/src/gen.zig index ec26295..dbfb1ba 100644 --- a/src/gen.zig +++ b/src/gen.zig @@ -96,23 +96,24 @@ fn genSite(ctx: *Context) !void { try std.fs.cwd().makePath(dstdir); } - const f = try std.fs.cwd().createFile(dstpath, .{}); + const f = try fs.FileSwapper.createAt(ctx.allocator(), dstpath); + defer f.close(); const page_name = try std.mem.replaceOwned(u8, ctx.allocator(), dstname, "_", " "); defer ctx.allocator().free(page_name); - try build(ctx.allocator(), f, page_name, srcpath); + try build(ctx.allocator(), f.writer().any(), page_name, srcpath); ctx.generated += 1; } } // build a single html file -fn build(allocator: std.mem.Allocator, f: std.fs.File, page_name: []const u8, srcpath: []const u8) !void { +fn build(allocator: std.mem.Allocator, w: std.io.AnyWriter, page_name: []const u8, srcpath: []const u8) !void { const mtime = try fs.get_mtime(allocator, srcpath); defer allocator.free(mtime); // HEAD - try f.writer().print( + try w.print( \\ \\ \\ @@ -138,30 +139,30 @@ fn build(allocator: std.mem.Allocator, f: std.fs.File, page_name: []const u8, sr }); // NAV - try f.writer().writeAll( + try w.writeAll( \\ \\ \\ ); // MAIN - try f.writer().print( + try w.print( \\
\\ , .{}); - try inject(allocator, f.writer().any(), srcpath); - try f.writer().writeAll( + try inject(allocator, w, srcpath); + try w.writeAll( \\
\\ ); // FOOTER - try f.writer().print( + try w.print( \\