aboutsummaryrefslogtreecommitdiff
path: root/doc/custom-writers.md
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-10-02 21:00:18 +0200
committerJohn MacFarlane <[email protected]>2022-10-03 08:47:32 -0700
commit309163f5bc88884b2f021ce480537d1f8c57e068 (patch)
tree27e998c87c9f0de613850d3c6c12b3b6f60466da /doc/custom-writers.md
parent3b0e70072023d519cfb97d25ab668cf0284a5e24 (diff)
[API Change] Base custom writers on Writer type.
The `T.P.Lua.writeCustom` function changed to allow either a TextWriter or ByteStringWriter to be returned. The global variables `PANDOC_DOCUMENT` and `PANDOC_WRITER_OPTIONS` are no longer set when the writer script is loaded. Both variables are still set in classic writers before the conversion is started, so they can be used when they are wrapped in functions.
Diffstat (limited to 'doc/custom-writers.md')
-rw-r--r--doc/custom-writers.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/custom-writers.md b/doc/custom-writers.md
index fc839c8a0..bb61be9da 100644
--- a/doc/custom-writers.md
+++ b/doc/custom-writers.md
@@ -81,7 +81,7 @@ end
Custom writers using the new style must contain a global function
named `Writer`. Pandoc calls this function with the document and
writer options as arguments, and expects the function to return a
-string.
+UTF-8 encoded string.
``` lua
function Writer (doc, opts)
@@ -89,6 +89,14 @@ function Writer (doc, opts)
end
```
+Writers that do not return text but binary data should define a
+function with name `BinaryWriter` instead. The function must still
+return a string, but it does not have to be UTF-8 encoded and can
+contain arbitrary binary data.
+
+If both `Writer` and `BinaryWriter` functions are defined, then
+only the `Writer` function will be used.
+
## Example: modified Markdown writer
Writers have access to all modules described in the [Lua filters