|
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 |