markdown_it.lua

changeset 21
3c71c525cec2
child 30
3ac53da03439
equal deleted inserted replaced
20:3b937ef20faa 21:3c71c525cec2
1 local markdown_it={}
2
3 local io = require('io')
4 local os = require('os')
5
6 function markdown_it.markdown(str, env)
7 -- Lua doesn't have bidirectional pipes without the posix library.
8 -- Keep things and compatible and use temporary files.
9 tmpname = os.tmpname()
10 file = io.open(tmpname, 'w')
11 file:write(str)
12 cmd = string.format("node '%s/markdown_it.js' '%s'",
13 env.paths.lgen_location,
14 tmpname)
15 io.stdout:write('Executing ' .. cmd .. '\n')
16 h = io.popen(cmd, 'r')
17 result = h:read("*a")
18 h:close()
19 file:close()
20 return result
21 end
22
23 return markdown_it

mercurial