@@ -167,3 +167,61 @@ function Doc (blocks, meta)
171+### Replacing placeholders with their metadata value
173+Lua filter functions are run in the order *Inlines → Blocks → Meta → Pandoc*.
174+Passing information from a higher level (e.g., metadata) to a lower level (e.g.,
175+inlines) is still possible by using two filters living in the same file:
180+function get_vars (meta)
181+ for k, v in pairs(meta) do
182+ if v.t == 'MetaInlines' then
183+ vars["$" .. k .. "$"] = v
188+function replace (el)
189+ if vars[el.text] then
190+ return pandoc.Span(vars[el.text])
196+return {{Meta = get_vars}, {Str = replace}}
199+If the contents of file `occupations.md` is
203+name: John MacFarlane
204+occupation: Professor of Philosophy
216+then running `pandoc --lua-filter=meta-vars.lua occupations.md` will output:
221+<dd><p><span>John MacFarlane</span></p>
224+<dd><p><span>Professor of Philosophy</span></p>