diff --git a/pygments.lua b/pygments.lua
index 3890e24..70659be 100644
--- a/pygments.lua
+++ b/pygments.lua
@@ -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
+}
diff --git a/pygments.moon b/pygments.moon
new file mode 100644
index 0000000..58612bb
--- /dev/null
+++ b/pygments.moon
@@ -0,0 +1,11 @@
+CodeBlock: (block) ->
+ 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"
+
+ pandoc.RawBlock "html", out
diff --git a/site.moon b/site.moon
index 4eff748..26cc5fd 100644
--- a/site.moon
+++ b/site.moon
@@ -13,6 +13,9 @@ import p from require "moon" -- debug
-- Change output dir to what Openresty prefers
Site.config.out_dir = "html/"
+-- Compile lua-filter used by Pandoc to highlight MoonScript syntax
+os.execute "moonc pygments.moon"
+
-- Configure the command our custom renderer uses to convert markdown to html
rend = "renderers.markdown"
require(rend).cmd = "pandoc --mathjax --lua-filter pygments.lua >"
@@ -120,13 +123,13 @@ sitegen.create =>
add "blog.html", title: "Posts", target: "posts/index", template: "blog"
add_all files_from "docs"
+ copy "app.css"
+ copy "moonscript.css"
+ copy "pygments.css"
+
-- replace post markdown yaml headers with moonscript headers
filter "docs", (body) =>
body\gsub "^%-%-%-.-%.%.%.", (yaml_header) ->
header = yaml_header\gsub "%-%-%-", "{"
moonscript_header = header\gsub "%.%.%.", "}"
moonscript_header
-
- copy "app.css"
- copy "moonscript.css"
- copy "pygments.css"
diff --git a/templates/root.html b/templates/root.html
index c1ac250..c46440e 100644
--- a/templates/root.html
+++ b/templates/root.html
@@ -12,7 +12,6 @@
media="screen"
/>
-