I am moving this from the discussion on pandoc-groups to here:
It would be great to be able to define the set of design meta-data in the YAML header of an document. The external filter pandoc-include provides this, but adds a new dependency and requires the include directive to be outside the YAML header block (which I think is suboptimal).
Ideally, we would have a LUA filter like include-meta that does something similar, i.e. allow specifying a single YAML file path or a list of those and adding the respective meta-data to the document meta-data.
So for instance, one would use include-meta in the YAML header of the document, like so:
title: The title
include-meta: acme-design-settings.yaml
or
title: The title
include-meta:
- acme-design-settings.yaml
- my-personal-meta-data.yaml
That would nicely complement the two other include filters:
The LUA filter for include-meta would basically follow this algorithm:
# pseudo-code
meta = document.meta
if meta.include-meta is not nil:
for each filename in meta.include-meta:
additional_meta = load_and_parse_yaml(filename)
for each entry in additional_meta:
if meta[entry.key] is nil:
meta[entry.key] = entry.value
# recursion not shown in here, needed for nested YAML
else:
if len(meta[entry.key]) == 1:
meta[entry.key] = list(meta[entry.key])
if len(entry.key) == 1:
entry.key = list(entry.key)
meta[entry.key].extend(entry.key)
The pseudocode is very sketchy in that the recursive addition of nested meta-data is not shown. Maybe there is an easy way to merge two or more Pandoc Meta objects and observe priority rules.
I have never used LUA before; I started sketching this out at
I am moving this from the discussion on pandoc-groups to here:
It would be great to be able to define the set of design meta-data in the YAML header of an document. The external filter
pandoc-include
provides this, but adds a new dependency and requires the include directive to be outside the YAML header block (which I think is suboptimal).Ideally, we would have a LUA filter like
include-meta
that does something similar, i.e. allow specifying a single YAML file path or a list of those and adding the respective meta-data to the document meta-data.So for instance, one would use
include-meta
in the YAML header of the document, like so:or
That would nicely complement the two other include filters:
The LUA filter for
include-meta
would basically follow this algorithm:The pseudocode is very sketchy in that the recursive addition of nested meta-data is not shown. Maybe there is an easy way to merge two or more Pandoc Meta objects and observe priority rules.
I have never used LUA before; I started sketching this out at
https://github.com/mfhepp/lua-filters/tree/master/include-meta
If anybody fluent with LUA is willing to work on this or help with advice, please do not hesitate :-)