I have an HTML template stored as a string variable, that is, echo $my_custom_html5_template
returns
<!DOCTYPE html>
etc.
Is it possible to pass this variable as a value of the --template
option?
That is, instead of using
pandoc input.md -s --template="my_custom_html5_template.html5" -o output.htm
I want to use something like
pandoc input.md -s --template=$my_custom_html5_template -o output.htm
Is it possible somehow?
If you're ok with using an extra file, then a custom Lua writer would do the trick.
--- Lua writer that behaves mostly like the HTML writer,
-- but takes the template from an environment variable.
Writer = function (doc, opts)
return pandoc.write(doc, {format='html5', extensions=opts.extensions}, opts)
end
Extensions = pandoc.format.extensions 'html5'
Template = os.getenv 'my_custom_html5_template'
or pandoc.template.default 'html5'
Usage:
pandoc -t my-html-writer.lua -s ...