简体   繁体   English

导入 lua 模块并将它们与 lua pandoc 过滤器一起使用

[英]Importing lua modules and using them with lua pandoc filter

Pandoc natively supports lua filter by its --lua-filter argument. Pandoc 通过其 --lua-filter 参数本身支持 lua 过滤器。
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.但是,我想知道它使用的是什么版本的 lua,以及是否可以将 lua 模块(如 luacom(我认为它依赖于 C 代码))导入其中。
This is part of my investigation to create a filter that reads excel worksheet and converts them to pandoc table.这是我创建一个过滤器来读取 Excel 工作表并将它们转换为 pandoc 表的调查的一部分。

It is generally possible to check the Lua version by running print(_VERSION) .通常可以通过运行print(_VERSION)来检查 Lua 版本。 Ie, running this in your shell should work:即,在你的 shell 中运行它应该可以工作:

pandoc --lua-filter <(echo 'print(_VERSION)') <<< ''

Older pandoc versions could be compiled with any of Lua 5.1, Lua 5.2, Lua 5.3, or LuaJIT.较旧的 pandoc 版本可以使用 Lua 5.1、Lua 5.2、Lua 5.3 或 LuaJIT 中的任何一个进行编译。 However, maintaining compatibility was burdensome, so the maintainer of the HsLua package used by pandoc (ie, I), stopped supporting older versions about a year ago.但是维护兼容性很麻烦,所以pandoc使用的HsLua包的维护者(即我)大约在一年前就停止支持旧版本了。 If you are using pandoc 2.3.1 or later, pandoc is guaranteed to contain Lua 5.3.x.如果您使用 pandoc 2.3.1 或更高版本,pandoc 保证包含 Lua 5.3.x。

Loading pure Lua libraries will be no problem and should work just as with a plain Lua executable.加载纯 Lua 库不会有问题,并且应该像使用普通的 Lua 可执行文件一样工作。 The only problem can be that the default LUA_PATH set in pandoc differs from that used in other programs.唯一的问题可能是LUA_PATH设置的默认 LUA_PATH 与其他程序中使用的不同。 This can happen if pandoc has not been compiled against the system-wide Lua version.如果 pandoc 没有针对系统范围的 Lua 版本编译,就会发生这种情况。 LuaRocks can help there, just run eval "$(luarocks path)" . LuaRocks可以提供帮助,只需运行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.与纯 Lua 库一样,如果 pandoc 已编译为非静态二进制文件,C Lua 库应该可以正常工作。 However, non-Windows binaries provided on the pandoc website and on GitHub are static, and dynamic loading of C libraries will not work.但是,pandoc 网站和 GitHub 上提供的非 Windows 二进制文件是静态的,无法动态加载 C 库。

We maintain Alpine-based Docker images , pandoc/core and pandoc/latex , which are compiled against the system-wide Lua version.我们维护基于 Alpine 的 Docker 镜像pandoc/corepandoc/latex ,它们是针对系统范围的 Lua 版本编译的。 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.如果您平台的包管理器没有提供最新的 pandoc 版本,不能使用静态编译的二进制文件,并且您不想自己编译 pandoc,这可能是一个不错的选择。 If you'd like to see support for other base image like Ubuntu, just raise a ticket.如果您想看到对 Ubuntu 等其他基本映像的支持,只需提出一张票即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM