WIP
This commit is contained in:
parent
58af575386
commit
e041143b27
23
pygments.lua
23
pygments.lua
@ -1,15 +1,26 @@
|
||||
return {
|
||||
CodeBlock = function(block)
|
||||
local fname = os.tmpname()
|
||||
do
|
||||
local _with_0 = io.open(fname, "w")
|
||||
_with_0:write(block.text)
|
||||
_with_0:close()
|
||||
end
|
||||
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")
|
||||
p:close()
|
||||
return pandoc.RawBlock("html", out)
|
||||
else
|
||||
local status, handle_or_error = pcall(function()
|
||||
return io.popen(("pygmentize -f html -l %s %s"):format(block.classes[1], fname))
|
||||
end)
|
||||
local sout = handle_or_error:read("*a")
|
||||
if block.classes[1] == "heex" then
|
||||
return block
|
||||
else
|
||||
return pandoc.RawBlock("html", sout)
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
@ -1,11 +1,33 @@
|
||||
CodeBlock: (block) ->
|
||||
fname = os.tmpname!
|
||||
with io.open fname, "w"
|
||||
\write block.text
|
||||
\close!
|
||||
|
||||
if block.classes[1] == "moon" or block.classes[1] == "moonscript"
|
||||
fname = os.tmpname!
|
||||
with io.open fname, "w"
|
||||
\write block.text
|
||||
\close!
|
||||
|
||||
p = io.popen ("pygmentize -f html -l moonscript.py %s -x")\format fname
|
||||
out = p\read"*a"
|
||||
|
||||
-- p = io.open fname
|
||||
out = p\read"*a"
|
||||
p\close!
|
||||
pandoc.RawBlock "html", out
|
||||
-- pandoc.RawBlock "html", "moonscript"
|
||||
else
|
||||
status, handle_or_error = pcall ->
|
||||
io.popen ("pygmentize -f html -l %s %s")\format block.classes[1], fname
|
||||
-- io.open fname
|
||||
|
||||
sout = handle_or_error\read"*a"
|
||||
-- handle_or_error\close!
|
||||
-- if sout\len! == 0 then block else pandoc.RawBlock "html", sout
|
||||
if block.classes[1] == "heex"
|
||||
-- pandoc.RawBlock "html", "heex"
|
||||
block
|
||||
else
|
||||
pandoc.RawBlock "html", sout
|
||||
|
||||
|
||||
-- p = io.open fname
|
||||
-- out = p\read"*a"
|
||||
-- p\close!
|
||||
-- pandoc.RawBlock "html", out
|
||||
|
@ -25,9 +25,9 @@ class PandocRenderer extends require "sitegen.renderers.markdown"
|
||||
p = io.open fname
|
||||
out = p\read"*a"
|
||||
|
||||
if mat = out\match('<div class="highlight"><pre>(.-)\n?</pre></div>')
|
||||
rep = '<div class="sourceCode"><pre class="sourceCode ' .. 'moonscript"><code class="sourceCode ' .. 'moonscript">' .. mat .. '</code></pre></div>'
|
||||
out = out\gsub('<div class="highlight"><pre>(.-)\n?</pre></div>', rep)
|
||||
-- if mat = out\match('<div class="highlight"><pre>(.-)\n?</pre></div>')
|
||||
-- rep = '<div class="sourceCode"><pre class="sourceCode ' .. 'moonscript"><code class="sourceCode ' .. 'moonscript">' .. mat .. '</code></pre></div>'
|
||||
-- out = out\gsub('<div class="highlight"><pre>(.-)\n?</pre></div>', rep)
|
||||
|
||||
out
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user