diff options
| -rw-r--r-- | src/gen.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gen.zig b/src/gen.zig index 3ea0bc2..6c7abcf 100644 --- a/src/gen.zig +++ b/src/gen.zig @@ -305,7 +305,7 @@ fn inject(allocator: std.mem.Allocator, w: std.io.AnyWriter, srcpath: []const u8 fn template(allocator: std.mem.Allocator, w: std.io.AnyWriter, refname: []const u8) anyerror!void { switch (refname[0]) { '/' => return try portal(allocator, w, refname[1..], false), - '@' => return try ref_link(allocator, w, refname[1..]), + '$' => return try ref_link(allocator, w, refname[1..]), '+' => return try ref_name(allocator, w, refname[1..]), else => return try ref(allocator, w, refname), } @@ -335,16 +335,19 @@ fn portal(allocator: std.mem.Allocator, w: std.io.AnyWriter, refname: []const u8 } fn ref(allocator: std.mem.Allocator, w: std.io.AnyWriter, refname: []const u8) anyerror!void { - const basename = try std.mem.replaceOwned(u8, allocator, refname, " ", "_"); + const endofref = std.mem.lastIndexOf(u8, refname, "#") orelse refname.len; + + const basename = try std.mem.replaceOwned(u8, allocator, refname[0..endofref], " ", "_"); defer allocator.free(basename); const refpathSite = try fs.join_path_and_filename(allocator, &.{Context.params.SITE_PATH}, &.{ basename, ".html" }); defer allocator.free(refpathSite); try w.print( - \\<a href="/{[PATH]s}">{[NAME]s}</a> + \\<a href="/{[PATH]s}{[anchor]s}">{[NAME]s}</a> , .{ - .NAME = refname, + .NAME = refname[0..endofref], .PATH = refpathSite, + .anchor = if (endofref < refname.len) refname[endofref..] else "", }); // XXX: track ref count? |