From ad92e5fc5e9f1d196b810aed1ec16c0face493df Mon Sep 17 00:00:00 2001 From: dvs1 Date: Mon, 20 Jan 2025 18:41:25 +1000 Subject: If we can't use cmark-gfm, then stick with the built in cmark instead. --- notYetAnotherWiki.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index c7b205d..90c8514 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua @@ -103,11 +103,18 @@ for name, file in pairs(Files) do else -- Ordinary md file, stash it's metadata and parsed body. -- I need cmark-gfm, coz lcmark doesn't support tables and stuff, it only does basic cmark. - -- Have to strip out the metadata first, coz cmark-gfm doesn't grok that. - h = io.popen('cp "' .. name .. '.md" "' .. name .. '02" ; csplit -ksz -f "' .. name .. '" "' .. name .. '.md" "/^---$/+1" "{1}" 2>/dev/null ; rm "' .. name .. '00" ; rm "' .. name .. '01" 2>/dev/null') - if nil ~= h then h:close() end - h = io.popen('cmark-gfm -t html -e footnotes -e table -e strikethrough -e autolink -e tagfilter -e tasklist "' .. name .. '02" ; rm "' .. name .. '02"') - if nil ~= h then body = h:read('*a') ; h:close() end + local out = '' + h = io.popen('if which cmark-gfm ; then echo "found" ; fi | tail -n 1') + if nil ~= h then out = h:read('a') ; h:close() end + if 'found\n' == out then + -- Have to strip out the metadata first, coz cmark-gfm doesn't grok that. + h = io.popen('cp "' .. name .. '.md" "' .. name .. '02" ; csplit -ksz -f "' .. name .. '" "' .. name .. '.md" "/^---$/+1" "{1}" 2>/dev/null ; rm "' .. name .. '00" ; rm "' .. name .. '01" 2>/dev/null') + if nil ~= h then h:close() end + h = io.popen('cmark-gfm -t html -e footnotes -e table -e strikethrough -e autolink -e tagfilter -e tasklist "' .. name .. '02" ; rm "' .. name .. '02"') + if nil ~= h then body = h:read('*a') ; h:close() end + else + print('cmark-gfm not found') + end Files[name].metadata = metadata Files[name].body = body table.insert(Subs[path].files, bit) -- cgit v1.1