Thank you, Albert! While this looks feasible & helpful, I have now (after many years of using Pandoc…) finally “seen the light”, and I’ll separate default files and metadata files, as it should be. 😊
Martin Post <martinpo...@gmail.com> writes:
> In a Pandoc document’s YAML metadata block, or in a Pandoc metadata file, I can do this:
>
> variable1: __content__
>
> …and it will be rendered as <strong>content</strong> for HTML.
>
> Doing this in a Pandoc DEFAULTS file:
>
> metadata:
> variable1: __content__
>
> …will render $variable1$ as “__content__”
>
> So – is it possible to have metadata in a defaults file interpreted as Markdown?
I think the only way would be to write a Lua filter that convert strings
to Inlines.
E.g.:
local strings2md
strings2md = function (meta)
for key, value in pairs(meta) do
if pandoc.utils.type(value) == 'string' then
-- Convert strings to Markdown
local blocks = pandoc.read(value).blocks
meta[key] = pandoc.utils.blocks_to_inlines(blocks)
elseif pandoc.utils.type(value) == 'List' then
-- Recurse on lists
meta[key] = strings2md(value)
end
end
return meta
end
Meta = strings2md
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124