@@ -38,7 +38,7 @@ JSON to stdout and reading it from stdin.
3838Here is an example of a lua filter that converts strong emphasis
3939to small caps:
4040
41−``` {.lua}
41+``` lua
4242return {
4343 {
4444 Strong = function (elem)
@@ -50,7 +50,7 @@ return {
5050
5151or equivalently,
5252
53−``` {.lua}
53+``` lua
5454function Strong(elem)
5555 return pandoc.SmallCaps(elem.c)
5656end
@@ -230,7 +230,7 @@ when added to `init.lua`. The snippet adds all unicode-aware
230230functions defined in the [`text` module](#module-text) to the
231231default `string` module, prefixed with the string `uc_`.
232232
233−``` {.lua}
233+``` lua
234234for name, fn in pairs(require 'text') do
235235 string['uc_' .. name] = fn
236236end
@@ -250,7 +250,7 @@ available at <https://github.com/pandoc/lua-filters>.
250250The following filter converts the string `{{helloworld}}` into
251251emphasized text "Hello, World".
252252
253−``` {.lua}
253+``` lua
254254return {
255255 {
256256 Str = function (elem)
@@ -270,7 +270,7 @@ This filter causes metadata defined in an external file
270270(`metadata-file.yaml`) to be used as default values in a
271271document's metadata:
272272
273−``` {.lua}
273+``` lua
274274-- read metadata file into string
275275local metafile = io.open('metadata-file.yaml', 'r')
276276local content = metafile:read("*a")
@@ -297,7 +297,7 @@ return {
297297This filter sets the date in the document's metadata to the
298298current date:
299299
300−``` {.lua}
300+``` lua
301301function Meta(m)
302302 m.date = os.date("%B %e, %Y")
303303 return m
@@ -309,7 +309,7 @@ end
309309This filter prints a table of all the URLs linked to in the
310310document, together with the number of links to that URL.
311311
312−``` {.lua}
312+``` lua
313313links = {}
314314
315315function Link (el)
@@ -350,13 +350,13 @@ Passing information from a higher level (e.g., metadata) to a
350350lower level (e.g., inlines) is still possible by using two
351351filters living in the same file:
352352
353−``` {.lua}
353+``` lua
354354local vars = {}
355355
356356function get_vars (meta)
357357 for k, v in pairs(meta) do
358− if v.t == 'MetaInlines' then
359− vars["$" .. k .. "$"] = {table.unpack(v)}
358+ if type(v) == 'table' and v.t == 'MetaInlines' then
359+ vars["%" .. k .. "%"] = {table.unpack(v)}
360360 end
361361 end
362362end
@@ -374,7 +374,7 @@ return {{Meta = get_vars}, {Str = replace}}
374374
375375If the contents of file `occupations.md` is
376376
377−``` {.markdown}
377+``` markdown
378378---
379379name: Samuel Q. Smith
380380occupation: Professor of Phrenology
@@ -382,17 +382,17 @@ occupation: Professor of Phrenology
382382
383383Name
384384
385−: \$name\$
385+: %name%
386386
387387Occupation
388388
389−: \$occupation\$
389+: %occupation%
390390```
391391
392392then running `pandoc --lua-filter=meta-vars.lua occupations.md`
393393will output:
394394
395−``` {.html}
395+``` html
396396<dl>
397397<dt>Name</dt>
398398<dd><p><span>Samuel Q. Smith</span></p>
@@ -410,7 +410,7 @@ pages. It converts level-1 headers to uppercase (using
410410`walk_block` to transform inline elements inside headers),
411411removes footnotes, and replaces links with regular text.
412412
413−``` {.lua}
413+``` lua
414414-- we use preloaded text to get a UTF-8 aware 'upper' function
415415local text = require('text')
416416
@@ -440,7 +440,7 @@ divs with class `handout`. (Note that only blocks at the "outer
440440level" are included; this ignores blocks inside nested
441441constructs, like list items.)
442442
443−``` {.lua}
443+``` lua
444444-- creates a handout from an article, using its headings,
445445-- blockquotes, numbered examples, figures, and any
446446-- Divs with class "handout"
@@ -469,7 +469,7 @@ document, since the latter will count markup characters, like
469469the `#` in front of an ATX header, or tags in HTML documents, as
470470words. To run it, `pandoc --lua-filter wordcount.lua myfile.md`.
471471
472−``` {.lua}
472+``` lua
473473-- counts words in a document
474474
475475words = 0
@@ -514,7 +514,7 @@ pandoc will use images in the mediabag. For textual formats, use
514514mediabag will be written, or (for HTML only) use
515515`--self-contained`.
516516
517−``` {.lua}
517+``` lua
518518-- Pandoc filter to process code blocks with class "abc" containing
519519-- ABC notation into images.
520520--
@@ -557,7 +557,7 @@ source, so that they need not be regenerated each time the
557557document is built. (A more sophisticated version of this might
558558put these in a special cache directory.)
559559
560−``` {.lua}
560+``` lua
561561local function tikz2image(src, filetype, outfile)
562562 local tmp = os.tmpname()
563563 local tmpdir = string.match(tmp, "^(.*[\\/])") or "."
@@ -1456,7 +1456,7 @@ UTF-8 aware text manipulation functions, implemented in Haskell.
14561456The module is made available as part of the `pandoc` module via
14571457`pandoc.text`. The text module can also be loaded explicitly:
14581458
1459−``` {.lua}
1459+``` lua
14601460-- uppercase all regular text in a document:
14611461text = require 'text'
14621462function Str (s)