I think I may have figured it out

This commit is contained in:
2025-06-16 20:18:05 -07:00
parent d22283905a
commit 92a1650e75
6 changed files with 90 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
sitegen = require "sitegen"
Site = require "sitegen.site"
Path = require "sitegen.path"
PygmentsPlugin = require "sitegen.plugins.pygments"
html = require "sitegen.html"
common = require "sitegen.common"
cosmo = require "sitegen.cosmo"
@@ -13,17 +14,40 @@ import p from require "moon" -- debug
-- Change output dir to what Openresty prefers
Site.config.out_dir = "html/"
-- PygmentsPlugin.highlight = (lang, code) =>
-- fname = os.tmpname!
-- with io.open fname, "w"
-- \write code
-- \close!
--
-- p lang
--
-- -- p = io.popen ("pygmentize -f html -l %s %s")\format lang, fname
-- p = io.popen ("pygmentize -f html -l moonscript.py %s -x")\format fname
-- out = p\read"*a"
--
-- -- get rid of the div and pre inserted by pygments
-- assert out\match('^<div class="highlight"><pre>(.-)\n?</pre></div>'),
-- "Failed to parse pygmentize result, is pygments installed?"
-- Configure the command our custom renderer uses to convert markdown to html
rend = "renderers.markdown"
require(rend).cmd = "pandoc --mathjax >"
-- require(rend).cmd = "pandoc --mathjax --no-highlight >"
-- require(rend).cmd = "pandoc --mathjax -f json >"
-- require(rend).cmd = "pandoc --mathjax --no-highlight --lua-filter ./pygments.lua >"
-- Insert custom renderer in the first position so it will be preferred
-- table.insert Site.default_renderers, 1, rend
table.insert Site.default_renderers, 1, rend
-- Remove "pygments" plugin because it conflicts with pandoc syntax highlighting
-- Site.default_plugins = for v in *Site.default_plugins
-- if v\find "pygments" then continue else v
Site.default_plugins = for v in *Site.default_plugins
if v\find "pygments" then continue else v
-- plugin = "plugins.pygments"
-- table.insert Site.default_plugins, 1, plugin
-- from https://github.com/leafo/sitegen/blob/v0.2/spec/sitegen_spec.moon#L9-L18
get_files = (path, prefix=path) ->
@@ -118,8 +142,8 @@ sitegen.create =>
} for path in *files
add "index.html", title: "Catalin Mititiuc"
-- add "blog.html", title: "Posts", target: "posts/index", template: "blog"
-- add_all files_from "docs"
add "blog.html", title: "Posts", target: "posts/index", template: "blog"
add_all files_from "docs"
-- replace post markdown yaml headers with moonscript headers
filter "docs", (body) =>
@@ -128,6 +152,7 @@ sitegen.create =>
moonscript_header = header\gsub "%.%.%.", "}"
moonscript_header
copy "moonscript.py"
copy "pygments.lua"
copy "app.css"
-- copy "pygments.css"
copy "moonscript.css"