diff options
author | ubq323 <ubq323@ubq323.website> | 2024-10-31 18:41:04 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-10-31 18:41:04 +0000 |
commit | d5e53ee2a2b83adf91a0c3bbbc02c450b6747d59 (patch) | |
tree | 6d08a0aa3e8eaa341e402b5881735ba79094ddc4 /prose.lua | |
parent | 664f471c774d6182efb0f9c4d4c9af9857b1bf52 (diff) |
highlighting, better whitespace, make into a module
Diffstat (limited to 'prose.lua')
-rw-r--r-- | prose.lua | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1,4 +1,5 @@ -local html = require'html' +local html = require'garkup.html' +local T = html.T local extensions = {} @@ -20,7 +21,7 @@ local function prose(S, text) local function simple_sub(delim, tagname) return { "(%s)"..delim..'(.-)'..delim..'(%W)', -- wo wimple - function(a,x,b) return a..emplace(html.T[tagname](x))..b end + function(a,x,b) return a..emplace(T[tagname](x))..b end } end @@ -76,15 +77,21 @@ extensions.fn = function(S,text) local n = #S.footnotes + 1 local link_id = "fnref_"..n local note_id = "fn_"..n - S.footnotes[n] = html.T.li({id=note_id}, { + S.footnotes[n] = true -- for nested footnotes + S.footnotes[n] = T.li({id=note_id}, { prose(S,text), html.safe" ", - html.T.a({href="#"..link_id, role="doc-backlink"}, html.safe"↩︎")}) - return html.T.sup({id=link_id}, html.T.a({href="#"..note_id, role='doc-noteref'}, '('..n..')')) + T.a({href="#"..link_id, role="doc-backlink"}, html.safe"↩︎")}) + return T.sup({id=link_id}, T.a({href="#"..note_id, role='doc-noteref'}, '('..n..')')) end extensions.fns = function(S) if not S.footnotes then return "" end - return {html.T.hr{}, html.T.ol(S.footnotes)} + return {T.hr"", T.ol(S.footnotes)} +end + +extensions.meta = function(S,text) + local fn = assert(load(string.format("return {%s}", text),"meta", "t")) + S.meta = fn() end return prose |