--- a/markdown_it.lua Mon Jul 06 13:34:06 2020 -0500 +++ b/markdown_it.lua Fri Jul 17 10:00:47 2020 -0500 @@ -2,6 +2,17 @@ local io = require('io') local os = require('os') +local path = require('mypath') +local lfs = require('lfs') + +function markdown_it.katex_config(env) + katex_config = path.join(env.paths.tmpl, "katex_config.json") + if lfs.attributes(katex_config) then + return katex_config + else + return nil + end +end function markdown_it.markdown(str, env) -- Lua doesn't have bidirectional pipes without the posix library. @@ -12,6 +23,11 @@ cmd = string.format("node '%s/markdown_it.js' '%s'", env.paths.lgen_location, tmpname) + -- Provide TEMPLATE_PATH/katex_config.json if it exists + katex_config = markdown_it.katex_config(env) + if katex_config then + cmd = cmd .. " '" .. katex_config .. "'" + end io.stdout:write('Executing ' .. cmd .. '\n') h = io.popen(cmd, 'r') result = h:read("*a") @@ -20,4 +36,11 @@ return result end +function markdown_it.add_deps(deps, env) + katex_config = markdown_it.katex_config(env) + if katex_config then + table.insert(deps, katex_config) + end +end + return markdown_it