markdown_it.lua

Mon, 06 Jul 2020 13:01:18 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 06 Jul 2020 13:01:18 -0500
changeset 28
9b75d0f5e042
parent 21
3c71c525cec2
child 30
3ac53da03439
permissions
-rw-r--r--

Use @neilsustc/markdown-it-katex instead of markdown-it-katex.
The latter is broken

local markdown_it={}

local io = require('io')
local os = require('os')

function markdown_it.markdown(str, env)
    -- Lua doesn't have bidirectional pipes without the posix library.
    -- Keep things and compatible and use temporary files.
    tmpname = os.tmpname()
    file = io.open(tmpname, 'w')
    file:write(str)
    cmd = string.format("node '%s/markdown_it.js' '%s'",
                        env.paths.lgen_location,
                        tmpname)
    io.stdout:write('Executing ' .. cmd .. '\n')
    h = io.popen(cmd, 'r')
    result = h:read("*a")
    h:close()
    file:close()
    return result
end

return markdown_it

mercurial