Write Pandoc lua-filter in MoonScript and compile to Lua on build

This commit is contained in:
2025-06-16 20:18:05 -07:00
parent 46aa6c829f
commit 895ef13d73
4 changed files with 32 additions and 16 deletions

View File

@@ -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"