From d5e53ee2a2b83adf91a0c3bbbc02c450b6747d59 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 31 Oct 2024 18:41:04 +0000 Subject: highlighting, better whitespace, make into a module --- prose.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'prose.lua') diff --git a/prose.lua b/prose.lua index ceadec0..99e298a 100644 --- a/prose.lua +++ b/prose.lua @@ -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 -- cgit v1.2.3