pandoc.lua

changeset 16
e377590e9b19
child 39
5fc5f93a8cad
equal deleted inserted replaced
15:82d254b8f01e 16:e377590e9b19
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

mercurial