fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

pandoc

Would you like to add via the command line, but feel limited because arguments to `--metadata`/`-M` are not treated as ? Here's a 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*!' …

@pandoc Interesting tip. It's worth nothing that "pandoc.read" takes a second optional argument, the format (default markdown), so using "djot" here for instance woudld allow metadata in #djot etc.
Subsequent question; can this be derived from the input file (or specified input format with -f) ?

@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'