Shared Lua modules for Quarto extensions: colour conversion, string escaping, metadata access, path resolution, schema checks, and values that Quarto 1 and Quarto 2 expose differently.
Quarto has no package manager for Lua. An extension therefore copies the modules it uses into its own repository, and commits them. The modules are not loaded from this repository at render time.
Full documentation is at https://m.canouil.dev/quarto-lua-modules/:
- Reference for every module and function.
- Vendoring for how to copy the modules in, declare them in
_dependencies.yml, and update them, by hand or withscripts/vendor.shfrom the release. - Examples for short working snippets.
Copy string.lua into _vendor/quarto-lua-modules/ in your extension, then load it from a filter:
local str = require(quarto.utils.resolve_path('_vendor/quarto-lua-modules/string.lua'):gsub('%.lua$', ''))
print(str.escape_html('Hello <World>'))The output is Hello <World>.
The modules run inside Quarto's Lua, and several of them call pandoc.*, so the tests run there too:
quarto pandoc lua tests/run.luaMIT.