Pandoc natively supports lua filter by its --lua-filter argument.
However, I am wondering however what version of lua is it using and whether it is possible to import lua modules such as luacom (which i believe relies on C code) into it.
This is part of my investigation to create a filter that reads excel worksheet and converts them to pandoc table.
It is generally possible to check the Lua version by running print(_VERSION)
. I.e., running this in your shell should work:
pandoc --lua-filter <(echo 'print(_VERSION)') <<< ''
or with pandoc 3.0 and later
pandoc lua -e 'print(_VERSION)'
Older pandoc versions could be compiled with any of Lua 5.1, Lua 5.2, Lua 5.3, or LuaJIT. However, maintaining compatibility was burdensome, so the maintainer of the HsLua package used by pandoc (i.e., I), stopped supporting older versions about a year ago. If you are using pandoc 2.3.1 or later, pandoc is guaranteed to contain Lua 5.3.x or newer. Starting with pandoc 3.0, pandoc ships with Lua 5.4.x.
Loading pure Lua libraries will be no problem and should work just as with a plain Lua executable. The only problem can be that the default LUA_PATH
set in pandoc differs from that used in other programs. This can happen if pandoc has not been compiled against the system-wide Lua version. LuaRocks can help there, just run eval "$(luarocks path)"
.
Same as with pure Lua libraries, C Lua libraries should just work if pandoc has been compiled as a non-static binary. However, non-Windows binaries provided on the pandoc website and on GitHub are static, and dynamic loading of C libraries will not work.
We maintain Alpine- and Ubuntu-based Docker images, pandoc/core
and pandoc/latex
, which are compiled against the system-wide Lua version. This can be a good option if your platform's package manager doesn't ship a recent pandoc version, can't use the statically compiled binary, and you don't want to compile pandoc yourself. If you'd like to see support for other base image, just raise a ticket.