Wed, 15 Dec 2021 10:37:47 +0200
Add ANTI-ABUSE LICENSE
16 | 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 .. '"' | |
39 | 13 | -- io.stdout:write('Executing ' .. cmd .. '\n') |
16 | 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 |