35 lines
913 B
Lua
35 lines
913 B
Lua
return {
|
|
CodeBlock = function(block)
|
|
local label
|
|
label = block.classes[1]
|
|
local cmd = "pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l %s %s"
|
|
local fname = os.tmpname()
|
|
do
|
|
local _with_0 = io.open(fname, "w")
|
|
_with_0:write(block.text)
|
|
_with_0:close()
|
|
end
|
|
local _exp_0 = label
|
|
if "moon" == _exp_0 or "moonscript" == _exp_0 then
|
|
local p = io.popen((cmd .. " -x"):format("moonscript.py", fname))
|
|
local out
|
|
do
|
|
local _with_0 = p:read("*a")
|
|
p:close()
|
|
out = _with_0
|
|
end
|
|
return pandoc.RawBlock("html", out)
|
|
else
|
|
local status, handle = pcall(function()
|
|
return io.popen(cmd:format(label or "text", fname))
|
|
end)
|
|
local out = handle:read("*a")
|
|
if out:len() == 0 then
|
|
return block
|
|
else
|
|
return pandoc.RawBlock("html", out)
|
|
end
|
|
end
|
|
end
|
|
}
|