There is an example lua filter in pandoc.org called:
"Replacing placeholders with their metadata value"
This does exactly what I need but for one exception:
If I set a metadata value on the pandoc command line with --metadata=KEY[:VALUE]
then the placeholder is not replaced with anything and not the command line VALUE
using this example lua filter.
Is there an easy fix for this?
I am pasting the example from https://pandoc.org/lua-filters.html below.
Thanks,
Howard
----
local vars = {}
function get_vars (meta)
for k, v in pairs(meta) do
if pandoc.utils.type(v) == 'Inlines' then
vars["%" .. k .. "%"] = {table.unpack(v)}
end
end
end
function replace (el)
if vars[el.text] then
return pandoc.Span(vars[el.text])
else
return el
end
end
return {{Meta = get_vars}, {Str = replace}}