aboutsummaryrefslogtreecommitdiff
path: root/doc/custom-writers.md
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-10-12 21:37:47 +0200
committerJohn MacFarlane <[email protected]>2022-10-14 10:37:37 -0700
commit8900b0f953798b01087e0135a3a9708a95eb7fde (patch)
treeb7221db3118cff0d81daf9282aa33c05536631f6 /doc/custom-writers.md
parent06ba4e9788eb5d53d566c01ad8e24aa91e104a74 (diff)
Lua: Support built-in default templates for custom writers
Custom writers can define a default template via a global `Template` function; the data directory is no longer searched for a default template. Writer authors can restore the old lookup behavior with ``` lua Template = function () local template return template.compile(template.default(PANDOC_SCRIPT_FILE)) end ```
Diffstat (limited to 'doc/custom-writers.md')
-rw-r--r--doc/custom-writers.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/custom-writers.md b/doc/custom-writers.md
index 038067a3e..aa2796d00 100644
--- a/doc/custom-writers.md
+++ b/doc/custom-writers.md
@@ -83,6 +83,17 @@ function Writer (doc, opts)
end
```
+## Default template
+
+The default template of a custom writer is defined by the return
+value of the global function `Template`. Pandoc uses the default
+template for rendering when the user has not specified a template,
+but invoked with the `-s`/`--standalone` flag.
+
+The `Template` global can be left undefined, in which case pandoc
+will throw an error when it would otherwise use the default
+template.
+
## Example: modified Markdown writer
Writers have access to all modules described in the [Lua filters
@@ -106,6 +117,11 @@ function Writer (doc, opts)
}
return pandoc.write(doc:walk(filter), 'gfm', opts)
end
+
+function Template ()
+ local template = pandoc.template
+ return template.compile(template.default 'gfm')
+end
```
[Lua filters documentation]: https://pandoc.org/lua-filters.html