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. 😊

Albert Krewinkel schrieb am Freitag, 29. September 2023 um 23:14:28 UTC+2:

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

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7f96f150-6981-4163-8f6d-54de50a90c4fn%40googlegroups.com.