I'm trying to recover, before trying to rewrite, a "classic" pandoc custom writer called tba.lua
.
Thus far, I've managed to make it work by adding the prescribed patch in the form
function Writer (doc, opts)
PANDOC_DOCUMENT = doc
PANDOC_WRITER_OPTIONS = opts
loadfile(PANDOC_SCRIPT_FILE)()
return pandoc.write_classic(doc, opts)
end
as stated in the documentation.
But then, I need to add always a --template
option to load the default template, as the writer with the --standalone
option complains about
No template defined in tba.lua
While seeing another example in the documentation, I tried to define the template in the writer by adding
function Template ()
local template = pandoc.template
return template.compile(template.default 'tba.lua')
end
Pandoc can now find the template default.tba.lua
in the --data-dir
directory, but now it complains saying
Error running Lua:
string expected, got pandoc Template
I thought that template.compile
would return the string and feed it to Pandoc, so I don't know what went wrong.
This was a documentation bug: pandoc used to expect a compiled template as the Template
parameter, but that was changed for various reasons. The documentation was updated to reflect this 5 days ago. It will be online after the next pandoc release.
Long story short, the below should work:
Template = pandoc.template.default 'tba.lua'