diff --git a/plugins/pygments.moon b/plugins/pygments.moon deleted file mode 100644 index 64565ad..0000000 --- a/plugins/pygments.moon +++ /dev/null @@ -1,61 +0,0 @@ -html = require "sitegen.html" - -class CustomPygments extends require "sitegen.plugins.pygments" - filter: (text, page) => - -- require("moon").p text - -- super(text, page) - text -- pandoc output - super(text, page) -- plugin output - - highlight: (lang, code) => - -- print "HIGHLIGHT CALLED" - -- require("moon").p code - fname = os.tmpname! - with io.open fname, "w" - \write code - \close! - - -- p = io.popen ("pygmentize -f html -l %s %s")\format lang, fname - -- out = p\read"*a" - -- - -- -- get rid of the div and pre inserted by pygments - -- assert out\match('^
(.-)\n?
'), - -- "Failed to parse pygmentize result, is pygments installed?" - - cmd = "pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l %s %s" - - if lang == "moon" or lang == "moonscript" - p = io.popen (cmd .. " -x")\format "moonscript.py", fname - -- -- p = io.popen (cmd)\format "moonscript", fname - - out = p\read"*a" - p\close! - -- out - - -- get rid of the div and pre inserted by pygments - assert out\match('^
(.-)\n?
'), - "Failed to parse pygmentize result, is pygments installed?" - else - if lang == nil or lang == "heex" - -- if block.classes[1] == nil - -- cb = pandoc.CodeBlock(block.text, class: "sourceCode") - -- pandoc.Div cb, class: "sourceCode" - -- else - -- block - -- "code(nil or heex): #{code}" - code - else - status, handle_or_error = pcall -> - io.popen (cmd)\format lang, fname - - sout = handle_or_error\read"*a" - handle_or_error\close! - - if sout\len! == 0 - -- "code: #{code}" - -- raw code - code - else - -- get rid of the div and pre inserted by pygments - assert sout\match('^
(.-)\n?
'), - "Failed to parse pygmentize result, is pygments installed?" diff --git a/site.moon b/site.moon index 59b3457..bfb6f6f 100644 --- a/site.moon +++ b/site.moon @@ -17,80 +17,17 @@ Site.config.out_dir = "html/" -- Compile lua-filter used by Pandoc to highlight MoonScript syntax os.execute "moonc pygments.moon" -try_compile = (text, options=implicitly_return_root: false) -> - to_lua text, options - --- PygmentsPlugin.highlight = (lang, code) => - -- fname = os.tmpname! - -- with io.open fname, "w" - -- \write code - -- \close! - -- - -- p = io.popen ("pygmentize -f html -l %s %s")\format lang, fname - -- out = p\read"*a" - -- - -- -- get rid of the div and pre inserted by pygments - -- assert out\match('^
(.-)\n?
'), - -- "Failed to parse pygmentize result, is pygments installed?" - - -- print "HIGHLIGHT CALLED" - -- - -- fname = os.tmpname! - -- with io.open fname, "w" - -- \write block.text - -- \close! - -- - -- cmd = "pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l %s %s" - -- - -- if lang == "moon" or lang == "moonscript" - -- -- p = io.popen ("pygmentize -f html -O style=dracula,wrapcode,classprefix=py- -l moonscript.py %s -x")\format fname - -- p = io.popen (cmd .. " -x")\format "moonscript.py", fname - -- -- p = io.popen (cmd)\format "moonscript", fname - -- - -- -- p = io.open fname - -- out = p\read"*a" - -- p\close! - -- out - -- -- pandoc.RawBlock "html", "moonscript" - -- else - -- if lang == nil or lang == "heex" - -- -- if block.classes[1] == nil - -- -- cb = pandoc.CodeBlock(block.text, class: "sourceCode") - -- -- pandoc.Div cb, class: "sourceCode" - -- -- else - -- -- block - -- - -- "code: #{code}" - -- else - -- status, handle_or_error = pcall -> - -- io.popen (cmd)\format lang, fname - -- -- io.open fname - -- - -- sout = handle_or_error\read"*a" - -- -- handle_or_error\close! - -- if sout\len! == 0 - -- -- cb = pandoc.CodeBlock(block.text, class: "sourceCode") - -- -- pandoc.Div cb, class: "sourceCode" - -- "code: #{code}" - -- else - -- -- pandoc.RawBlock "html", sout - -- sout - -- Configure the command our custom renderer uses to convert markdown to html rend = "renderers.markdown" --- require(rend).cmd = "pandoc --mathjax --no-highlight >" -require(rend).cmd = "pandoc --mathjax >" --- require(rend).cmd = "pandoc --mathjax --lua-filter pygments.lua >" +require(rend).cmd = "pandoc --mathjax --lua-filter pygments.lua >" -- Insert custom renderer in the first position so it will be preferred table.insert Site.default_renderers, 1, rend --- Remove "pygments" plugin +-- Remove Pygments plugin Site.default_plugins = for v in *Site.default_plugins if v\find "pygments" then continue else v -table.insert Site.default_plugins, 1, "plugins.pygments" - -- from https://github.com/leafo/sitegen/blob/v0.2/spec/sitegen_spec.moon#L9-L18 get_files = (path, prefix=path) -> files = Path.read_exec "find", path, "-type", "f" @@ -195,23 +132,6 @@ sitegen.create => publish_date: format_date date true -- add_all files_from "docs" - -- with PygmentsPlugin.custom_highlighters - -- .moon = (code_text, page, options) => - -- lua_text, err = try_compile code_text, options - -- return err if not lua_text - -- - -- html.build -> - -- tag.span "moon custom highlighter" - -- - -- .heex = (code_text, page, options) => - -- lua_text, err = try_compile code_text, options - -- return err if not lua_text - -- - -- html.build -> - -- tag.span "heex custom highlighter" - - - copy "app.css" copy "pygments.css" copy "moonscript.css" diff --git a/templates/root.html b/templates/root.html index f7a4c54..8d00846 100644 --- a/templates/root.html +++ b/templates/root.html @@ -11,9 +11,8 @@ type="text/css" media="screen" /> - - - + $each{{"pandoc", "pygments", "app"}, "stylesheet"}[[ + ]]