Write Pandoc lua-filter in MoonScript and compile to Lua on build

This commit is contained in:
2025-06-16 20:18:05 -07:00
parent 46aa6c829f
commit 895ef13d73
4 changed files with 32 additions and 16 deletions

View File

@@ -1,12 +1,15 @@
function CodeBlock(block)
if block.classes[1] == "moon" or block.classes[1] == "moonscript" then
local fname = os.tmpname()
local handle = io.open(fname, "w")
handle:write(block.text)
handle:close()
local p = io.popen(string.format("pygmentize -f html -l moonscript.py %s -x", fname))
local out = p:read("*a")
return pandoc.RawBlock("html", out)
return {
CodeBlock = function(block)
if block.classes[1] == "moon" or block.classes[1] == "moonscript" then
local fname = os.tmpname()
do
local _with_0 = io.open(fname, "w")
_with_0:write(block.text)
_with_0:close()
end
local p = io.popen(("pygmentize -f html -l moonscript.py %s -x"):format(fname))
local out = p:read("*a")
return pandoc.RawBlock("html", out)
end
end
end
}