Would you like to add #metadata via the command line, but feel limited because arguments to `--metadata`/`-M` are not treated as #Markdown? Here's a #LuaFilter to solve this:
function Meta (meta)
for key, value in pairs(meta) do
if type(value) == 'string' then
meta[key] = pandoc.utils.blocks_to_inlines(
pandoc.read(value).blocks)
end
end
return meta
end
Example:
pandoc -L parse-md-in-metadata.lua \
-M title='Defend democracy *now*!' …
@omikhleia Choosing a format based on the name of the input file:
local format =
pandoc.format.from_path(
PANDOC_STATE.input_files[1] or
'placeholder.md')
Information about the input format is not retained, filters have no information about the actual parser that was used to read the input. This is intentional.
A variable could be used to gain fine-grained control, e.g.
local format = tostring(PANDOC_WRITER_OPTIONS.variables.metaformat) or 'markdown'