|
1 local pandoc={} |
|
2 |
|
3 local io = require('io') |
|
4 local os = require('os') |
|
5 |
|
6 function pandoc.pandoc(str) |
|
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 = 'pandoc --from=markdown --to=html "' .. tmpname .. '"' |
|
13 io.stdout:write('Executing ' .. cmd .. '\n') |
|
14 h = io.popen(cmd, 'r') |
|
15 result = h:read("*a") |
|
16 h:close() |
|
17 file:close() |
|
18 return result |
|
19 end |
|
20 |
|
21 return pandoc |