about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2025-10-05 18:32:28 +0200
committerRobert Günzler <r@gnzler.io>2025-10-06 14:32:30 +0200
commit824620ab6ca3326007e67e4753d2dab3af5b59e8 (patch)
tree86dc6ac43046b969666ab674293ea48ea8c6e815
parent802203b9bb43d74cdf0f3ae25fb850c922aa3ccd (diff)
downloadsite-824620ab6ca3326007e67e4753d2dab3af5b59e8.tar.gz
runPandoc: use the separate swap api
Signed-off-by: Robert Günzler <r@gnzler.io>
-rw-r--r--src/exe.zig58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/exe.zig b/src/exe.zig
index f0d55d4..4d9573e 100644
--- a/src/exe.zig
+++ b/src/exe.zig
@@ -41,37 +41,37 @@ fn pandocWorker(ctx: *Context, page: []const u8) !void {
     defer ctx.allocator().free(mtime_str);
 
     const f = try fs.FileSwapper.createAt(ctx.allocator(), target_path);
+    defer f.close();
 
     // open new scope to close the file swapper when we're done writing
-    {
-        defer f.close();
-
-        try f.writer().print(
-            \\<!-- Generated file, you may edit and discard {s} :) -->
-            \\
-        ,
-            .{page},
-        );
-
-        // make pandoc runs reproducable
-        var env_map = std.process.EnvMap.init(ctx.allocator());
-        defer env_map.deinit();
-        try env_map.put("SOURCE_DATE_EPOCH", mtime_str);
-
-        try captureStdout(ctx, &.{
-            Context.params.PANDOC,
-            "--from",
-            "markdown+wikilinks_title_after_pipe+autolink_bare_uris",
-            "--to",
-            "html5",
-            "--lua-filter",
-            // TODO: embed the preproc filter
-            Context.params.PANDOC_PREPROC,
-            "--strip-comments",
-            "--output=-",
-            source_path,
-        }, &env_map, f.writer().any());
-    }
+    try f.writer().print(
+        \\<!-- Generated file, you may edit and discard {s} :) -->
+        \\
+    ,
+        .{page},
+    );
+
+    // make pandoc runs reproducable
+    var env_map = std.process.EnvMap.init(ctx.allocator());
+    defer env_map.deinit();
+    try env_map.put("SOURCE_DATE_EPOCH", mtime_str);
+
+    try captureStdout(ctx, &.{
+        Context.params.PANDOC,
+        "--from",
+        "markdown+wikilinks_title_after_pipe+autolink_bare_uris",
+        "--to",
+        "html5",
+        "--lua-filter",
+        // TODO: embed the preproc filter
+        Context.params.PANDOC_PREPROC,
+        "--strip-comments",
+        "--output=-",
+        source_path,
+    }, &env_map, f.writer().any());
+
+    // swap now, we want to edit mtime
+    try f.swap();
 
     // fixup mtime of the resulting file, this has to happen after the file
     // swapper has been closed, because it works on a tmp file which is going