@@ -167,3 +167,61 @@ function Doc (blocks, meta)
167167 )
168168end
169169```
170+
171+### Replacing placeholders with their metadata value
172+
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:
176+
177+``` lua
178+local vars = {}
179+
180+function get_vars (meta)
181+ for k, v in pairs(meta) do
182+ if v.t == 'MetaInlines' then
183+ vars["$" .. k .. "$"] = v
184+ end
185+ end
186+end
187+
188+function replace (el)
189+ if vars[el.text] then
190+ return pandoc.Span(vars[el.text])
191+ else
192+ return el
193+ end
194+end
195+
196+return {{Meta = get_vars}, {Str = replace}}
197+```
198+
199+If the contents of file `occupations.md` is
200+
201+``` markdown
202+---
203+name: John MacFarlane
204+occupation: Professor of Philosophy
205+---
206+
207+Name
208+
209+: \$name\$
210+
211+Occupation
212+
213+: \$occupation\$
214+```
215+
216+then running `pandoc --lua-filter=meta-vars.lua occupations.md` will output:
217+
218+``` html
219+<dl>
220+<dt>Name</dt>
221+<dd><p><span>John MacFarlane</span></p>
222+</dd>
223+<dt>Occupation</dt>
224+<dd><p><span>Professor of Philosophy</span></p>
225+</dd>
226+</dl>
227+```