diff options
-rwxr-xr-x | notYetAnotherWiki.lua | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 44f311c..f124eeb 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
@@ -31,6 +31,7 @@ local GlobalMetaData = { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | local Files, Subs, xLinks = {}, {}, {} | 33 | local Files, Subs, xLinks = {}, {}, {} |
34 | local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding. | ||
34 | 35 | ||
35 | local Template = '' | 36 | local Template = '' |
36 | local h = io.open("default.template", 'r') | 37 | local h = io.open("default.template", 'r') |
@@ -87,6 +88,7 @@ local toFile = function(name, key, value) | |||
87 | local bits, bit = stringBits(name) | 88 | local bits, bit = stringBits(name) |
88 | local path = '' | 89 | local path = '' |
89 | Files[name] = {} | 90 | Files[name] = {} |
91 | Files[name].headers = {} | ||
90 | Files[name].bits = bits | 92 | Files[name].bits = bits |
91 | Files[name].bit = bit | 93 | Files[name].bit = bit |
92 | for i, d in ipairs(bits) do | 94 | for i, d in ipairs(bits) do |
@@ -107,6 +109,7 @@ local toFile = function(name, key, value) | |||
107 | h = io.open(name .. '.md', 'r') | 109 | h = io.open(name .. '.md', 'r') |
108 | if nil ~= h then | 110 | if nil ~= h then |
109 | -- print('Parsing ' .. name .. '.md') | 111 | -- print('Parsing ' .. name .. '.md') |
112 | Context = Files[name] | ||
110 | body = h:read('*a') ; h:close() | 113 | body = h:read('*a') ; h:close() |
111 | -- Deal with my typical double spaced sentence endings, and other things. | 114 | -- Deal with my typical double spaced sentence endings, and other things. |
112 | local result = RE.compile( [=[{~ | 115 | local result = RE.compile( [=[{~ |
@@ -123,8 +126,9 @@ local toFile = function(name, key, value) | |||
123 | {"[" {([^]])+} "]{style='color: " {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" / | 126 | {"[" {([^]])+} "]{style='color: " {([^}])+} "}" } -> "<span style='color: %3;'>%2</span>" / |
124 | {"{#"[A-Za-z_]+"}"} -> '' / | 127 | {"{#"[A-Za-z_]+"}"} -> '' / |
125 | {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' / | 128 | {"### [[edit](/bin/edit/Main/" {([^%nl])+} } -> '' / |
129 | {"#"+ " " {([^%nl])+} } -> header / | ||
126 | . | 130 | . |
127 | )* ~}]=], { } ):match(body) | 131 | )* ~}]=], { header = function(a) table.insert(Context.headers, a); return a end } ):match(body) |
128 | body = result | 132 | body = result |
129 | -- {"<!--".*"-->"} -> '' / | 133 | -- {"<!--".*"-->"} -> '' / |
130 | -- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later. | 134 | -- {"[$]"} -> '$dlr$' / -- Replace $, coz otherwise it confuses things later. |
@@ -646,7 +650,6 @@ local LunamarkOpts = { | |||
646 | } | 650 | } |
647 | local Writer = Lunamark.writer.html5.new(LunamarkOpts) | 651 | local Writer = Lunamark.writer.html5.new(LunamarkOpts) |
648 | -- Can override the various writer functions, there's something for each of the basic HTML elements. | 652 | -- Can override the various writer functions, there's something for each of the basic HTML elements. |
649 | local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding. | ||
650 | local lunaLinky = function(url) -- Fix up the links. | 653 | local lunaLinky = function(url) -- Fix up the links. |
651 | if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then | 654 | if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then |
652 | -- TODO - This might be covering up a bug elsewhere. | 655 | -- TODO - This might be covering up a bug elsewhere. |
@@ -770,7 +773,18 @@ for name, file in pairs(Files) do | |||
770 | url = Files[file.path .. '/' .. f].metadata.URL | 773 | url = Files[file.path .. '/' .. f].metadata.URL |
771 | end | 774 | end |
772 | if nil == title then title = f end | 775 | if nil == title then title = f end |
773 | if bit == f then metadata.menu = metadata.menu .. '<p>' .. title .. '</p>' | 776 | if bit == f then |
777 | metadata.menu = metadata.menu .. '<p>' .. title .. '</p>' | ||
778 | for j, g in ipairs(file.headers) do | ||
779 | g = RE.gsub(g, '{[#]}', ' ') | ||
780 | g = RE.gsub(g, '{[ ]}', ' ') | ||
781 | local beg, en = RE.find(g, [['{']]) | ||
782 | if nil ~= beg then | ||
783 | g = string.sub(g, 1, beg - 7) | ||
784 | end | ||
785 | -- FIXME - if it's a linky, strip off the URL part. The Wiki audit has such things. | ||
786 | metadata.menu = metadata.menu .. '<p style="font-size: 0.80em;">' .. g .. '</p>' | ||
787 | end | ||
774 | else | 788 | else |
775 | if nil ~= url then metadata.menu = metadata.menu .. '<p><a href="' .. url .. '">' .. title .. ' ☝</a></p>' | 789 | if nil ~= url then metadata.menu = metadata.menu .. '<p><a href="' .. url .. '">' .. title .. ' ☝</a></p>' |
776 | else metadata.menu = metadata.menu .. '<p><a href="' .. f .. '.HTML">' .. title .. '</a></p>' | 790 | else metadata.menu = metadata.menu .. '<p><a href="' .. f .. '.HTML">' .. title .. '</a></p>' |