CodeBlock: (block) -> fname = os.tmpname! with io.open fname, "w" \write block.text \close! cmd = "pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l %s %s" if block.classes[1] == "moon" or block.classes[1] == "moonscript" -- p = io.popen ("pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l moonscript.py %s -x")\format fname p = io.popen (cmd .. " -x")\format "moonscript.py", fname -- p = io.popen (cmd)\format "moonscript", fname -- p = io.open fname out = p\read"*a" p\close! pandoc.RawBlock "html", out -- pandoc.RawBlock "html", "moonscript" else if block.classes[1] == nil or block.classes[1] == "heex" -- pandoc.RawBlock "text", block.text -- require("moon").p [k for k,v in pairs block] -- tb = pandoc.RawBlock "html", if block.classes[1] == nil cb = pandoc.CodeBlock(block.text, class: "sourceCode") pandoc.Div cb, class: "sourceCode" else block -- pandoc.CodeBlock block.text, "text" else status, handle_or_error = pcall -> io.popen (cmd)\format block.classes[1], fname -- io.open fname sout = handle_or_error\read"*a" -- handle_or_error\close! if sout\len! == 0 cb = pandoc.CodeBlock(block.text, class: "sourceCode") pandoc.Div cb, class: "sourceCode" else pandoc.RawBlock "html", sout -- if mat = sout\match('
(.-)\n?
') -- rep = '
' .. mat .. '
' -- sout = sout\gsub('
(.-)\n?
', rep) -- pandoc.RawBlock "html", sout -- sout = if status then "true" else "false" -- pandoc.RawBlock "html", sout -- if mat = out\match('
(.-)\n?
') -- rep = '
' .. mat .. '
' -- out = out\gsub('
(.-)\n?
', rep) -- p = io.open fname -- out = p\read"*a" -- p\close! -- pandoc.RawBlock "html", out