pandoc.lua

Wed, 08 Jul 2026 19:48:16 +0300

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 08 Jul 2026 19:48:16 +0300
changeset 48
fc30e7d53909
parent 39
5fc5f93a8cad
permissions
-rw-r--r--

Fix issue with a const variable assign in lua 5.5

local pandoc={}

local io = require('io')
local os = require('os')

function pandoc.pandoc(str)
    -- Lua doesn't have bidirectional pipes without the posix library.
    -- Keep things and compatible and use temporary files.
    tmpname = os.tmpname()
    file = io.open(tmpname, 'w')
    file:write(str)
    cmd = 'pandoc --from=markdown --to=html "' .. tmpname .. '"'
    -- io.stdout:write('Executing ' .. cmd .. '\n')
    h = io.popen(cmd, 'r')
    result = h:read("*a")
    h:close()
    file:close()
    return result
end

return pandoc

mercurial