27 lines
721 B
Plaintext
27 lines
721 B
Plaintext
CodeBlock: (block) ->
|
|
{ label } = block.classes
|
|
cmd = "pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l %s %s"
|
|
fname = os.tmpname!
|
|
|
|
with io.open fname, "w"
|
|
\write block.text
|
|
\close!
|
|
|
|
switch label
|
|
when "moon", "moonscript"
|
|
p = io.popen (cmd .. " -x")\format "moonscript.py", fname
|
|
out = with p\read"*a"
|
|
p\close!
|
|
-- syntax highlight with pygments
|
|
pandoc.RawBlock "html", out
|
|
else
|
|
status, handle = pcall -> io.popen cmd\format label or "text", fname
|
|
out = handle\read"*a"
|
|
|
|
if out\len! == 0
|
|
-- syntax highlight with pandoc
|
|
block
|
|
else
|
|
-- syntax highlight with pygments
|
|
pandoc.RawBlock "html", out
|