From 6be63601ba1c2cd76aa1eca2ee349492f3360aa4 Mon Sep 17 00:00:00 2001
From: dvs1
Date: Fri, 14 Mar 2025 21:34:10 +1000
Subject: Make the TOC actually work.
---
TODO.md | 2 +-
notYetAnotherWiki.lua | 16 +++++++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/TODO.md b/TODO.md
index 1c87341..acdcfe2 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,8 +6,8 @@ Make it perphekd!
TOC
-- Add anchors, so clicking on them goes to the heading.
- Lengthy headings need to be tamed.
+- Need a "go to top" linky after each heading now.
Check the timestamps on the files, only update if source is newer than destination. Meh, it's already 600 times faster than the pandoc version.
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index f124eeb..3590af7 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -710,6 +710,10 @@ local lunaLinky = function(url) -- Fix up the links.
return url
end
+function Writer.header(s, level)
+ local text = table.concat(s)
+ return '
' .. title .. '
' for j, g in ipairs(file.headers) do - g = RE.gsub(g, '{[#]}', ' ') - g = RE.gsub(g, '{[ ]}', ' ') - local beg, en = RE.find(g, [['{']]) + local h = string.sub(RE.gsub(g, '{[#]}', ''), 2) + local l = string.len(g) - string.len(h) + g = h + h = RE.gsub(h, '{[ ]}', ' ') + local beg, en = RE.find(h, [['{']]) if nil ~= beg then - g = string.sub(g, 1, beg - 7) + g = string.sub(h, 1, beg - 7) end -- FIXME - if it's a linky, strip off the URL part. The Wiki audit has such things. - metadata.menu = metadata.menu .. '' .. g .. '
' + metadata.menu = metadata.menu .. '' .. string.rep(' ', l) .. '' .. h .. '
' end else if nil ~= url then metadata.menu = metadata.menu .. '' -- cgit v1.1