From dc810e9fa3a08552d9ea1e949970d4da34b21ab0 Mon Sep 17 00:00:00 2001
From: onefang
Date: Thu, 5 Feb 2026 12:40:57 +1000
Subject: More polygLua conversions.
---
notYetAnotherWiki.lua | 32 +++++++-------------------------
1 file changed, 7 insertions(+), 25 deletions(-)
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index f082eba..fb581e3 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -46,25 +46,6 @@ end
---------------------------------------------------------------------------------
-- Useful functions, part 0.
--- A simple table.subtable = subtable wont work, you end up with a reference so that changes to the later get applied to the former.
-local derefiTable = function(t, strip)
- local argh = {}
- for l, y in ipairs(t) do if (l ~= y.name) and strip then table.insert(argh, y) end end
- return argh
-end
-local derefTable = function(t, strip)
- local argh = {}
- for l, y in pairs(t) do argh[l] = y end
- return argh
-end
-
-
-local writeString = function(base, body)
- local a, e = io.open(base, 'w')
- if nil == a then print('Could not open ' .. base .. ' - ' .. e) else
- a:write(body)
- a:close()
- end
end
@@ -314,7 +295,7 @@ os.execute('cp ' .. l .. ' ' .. l .. '_ORIGINAL0')
h = io.open(l, 'r')
if nil ~= h then
local body = h:read('*a') ; h:close()
-writeString(l .. '_ORIGINAL1', body)
+_.string2file(body, l .. '_ORIGINAL1')
if 'Foswiki' == l:sub(1, 7) then
-- Strip out the actual content.
local beg, en = RE.find(body, [['
']]) if nil ~= beg then body = body:sub(en + 1) end
@@ -390,7 +371,7 @@ writeString(l .. '_ORIGINAL1', body)
]=]
end
- writeString(l .. '_NEW', body)
+ _.string2file(body, l .. '_NEW')
elseif 'PmWiki' == l:sub(1, 6) then
local beg, en = RE.find(body, [['']]) if nil ~= beg then body = body:sub(en + 2) end
beg, en = RE.find(body, [["div id='wikitext'>"]]) if nil ~= beg then body = body:sub(en + 2) end
@@ -448,7 +429,7 @@ writeString(l .. '_ORIGINAL1', body)
--if nil ~= en then D('HTM1 ' .. body:sub(beg, en + 84) .. ' \t\t') end
end
- writeString(l .. '_NEW', body)
+ _.string2file(body, l .. '_NEW')
end
end
@@ -635,7 +616,8 @@ end
local Bdy = '# All the pages\n\n| page | original page | last edited UTC | \n| --------- | ------- | --------------- | '
Pages = {}
for name, file in pairs(Files) do
- local metadata = derefTable(Files[name].metadata, true)
+-- FIXME - don't think the deref is needed here, metedata isn't changed.
+ local metadata = _.derefTable(Files[name].metadata)
if ('everything' ~= name) then
local ln, fw, pw, ts = 'DUNNO', '', '', ''
local title, link = whichWiki(metadata)
@@ -864,7 +846,7 @@ local Parse = Lunamark.reader.markdown.new(Writer, LunamarkOpts)
---------------------------------------------------------------------------------
-- Loop through the files we found and actually create their HTML files.
for name, file in pairs(Files) do
- local body, metadata = Files[name].body, derefTable(Files[name].metadata, true)
+ local body, metadata = Files[name].body, _.derefTable(Files[name].metadata)
local bits, bit = Files[name].bits, Files[name].bit
local ln = #bits
local result = ''
@@ -1000,8 +982,8 @@ for name, file in pairs(Files) do
-- Write the file.
if '' ~= result then
- writeString(name .. '.HTML', result)
-- D('From ' .. name .. '.md -> ' .. base)
+ _.string2file(result, name .. '.HTML')
end
end
end
--
cgit v1.1