Run Pandoc Lua filters in Rust
Weavon compiles Lua 5.4.8 and LPeg 1.1.0 into the binary and matches all 468 of 468 Pandoc 3.13 Lua API names.
Full Lua 5.4 API parity at Rust speed
- 468 of 468Pandoc 3.13 Lua APIs match
- 5.51 msLua filter startup CPU, Pandoc needs 21.49 ms
- 782 ms1.29 MB filter CPU, Pandoc needs 4,887 ms
- LPeg 1.1.0Bundled for custom readers
Your existing Lua filters run unchanged
Pass --lua-filter, -f reader.lua, or -t writer.lua just as you do in Pandoc. You can also run standalone scripts with weavon lua.
-- shift-headings.lua
function Header(el)
el.level = math.min(el.level + 1, 6)
return el
end
weavon guide.md --lua-filter shift-headings.lua -o guide.html
What is included in the runtime
- Full
pandocmodule constructors and AST traversal pandoc.utils,pandoc.path,pandoc.json, andpandoc.system- Bundled LPeg 1.1.0 and
regrammar library - Custom Lua readers (
-f custom.lua) and writers (-t custom.lua) - JSON filters (
--filter) when you need external processes - In-process Python and Node AST
walkfilters without Lua
Test your Lua filters on Weavon
Run your Lua filter
Invoke Weavon with the same
--lua-filterflag that Pandoc uses.weavon doc.md --lua-filter filter.lua -o out.htmlCheck exact Pandoc parity
Pass
--compat=pandoc-3.13to verify byte-identical output against Pandoc.weavon --compat=pandoc-3.13 doc.md --lua-filter filter.lua -o weavon.htmlRun standalone Lua scripts
Use
weavon luaorpandoc luafor scripts that import thepandocmodules.weavon lua inspect.lua doc.md
Common questions
How many Pandoc Lua APIs does Weavon support?
All 468 of 468 Pandoc 3.13 Lua 5.4 API names match, including pandoc.utils, pandoc.path, pandoc.json, pandoc.mediabag, and LPeg 1.1.0.
How fast are Lua filters in Weavon?
On the 1.29 MB Markdown identity Lua filter benchmark, Weavon takes 782.34 ms CPU compared with 4,887.11 ms in Pandoc 3.13, more than 6 times faster.
Do custom Lua readers and writers work?
Yes. Pass -f custom.lua for a custom reader or -t custom.lua for a custom writer, with LPeg 1.1.0 built in.
Can I write filters in Python or JavaScript instead of Lua?
Yes. Both bindings/python and bindings/node expose a typed Pandoc AST and a bottom-up walk function inside your host process.
