Repository navigation
Plugins and Pandoc
Leafmark extensions are Pandoc Lua filters plus optional Pandoc arguments. They can be project-owned (plugins) or theme-owned (themePlugins).
{
"plugins": ["plugins/cleanup.lua"]
}The string is resolved from the active project and passed as --lua-filter=<path>.
{
"plugins": [
{
"luaFilter": "plugins/layout.lua",
"args": ["--wrap=none"],
"pdfArgs": ["-V", "colorlinks=true"],
"htmlArgs": ["--section-divs"],
"docxArgs": []
}
]
}path is accepted as an alias for luaFilter. args applies to every format; the matching format array is appended for PDF, HTML, or DOCX.
function Header(header)
if header.level == 1 then
header.classes:insert("chapter-title")
end
return header
endRefer to the Pandoc Lua filters manual for the complete AST API.
For each output, Leafmark adds:
- theme plugins;
- project plugins;
-
pandoc.args; - the matching
pandoc.pdfArgs,pandoc.htmlArgs, orpandoc.docxArgs.
Leafmark may also add bundled filters for author entries and bibliography page breaks. Pandoc processes filter arguments in command-line order.
Use the pandoc object when no custom filter is needed:
{
"pandoc": {
"args": ["--wrap=none"],
"pdfArgs": ["-V", "papersize=letter"],
"htmlArgs": ["--section-divs"],
"docxArgs": ["--reference-doc=reference.docx"]
}
}Arguments are not validated by Leafmark. Check the installed Pandoc version because option availability can differ.
Pandoc searches the active project, parent project, input root, and Leafmark package resources. Plugin and config paths themselves resolve from the active project unless absolute.
- Run with
--keep-build-files. - Inspect
_merged.mdin the output directory. - Temporarily remove other filters to isolate ordering problems.
- Run the equivalent Pandoc command or a minimal Pandoc fixture directly.
- Remember that PDF, HTML, and DOCX AST handling may differ.
Caution
Plugin arguments can override Leafmark defaults or make an invalid Pandoc command. Keep format-specific settings in the matching array and document any required external tools.
Leafmark documentation · Source repository · npm
Leafmark Wiki
Authoring
Configuration
Building
Help