New templates variables can be added by giving variable-value pairs as a
second return value of the global function `Doc`.
Example:
function Doc (body, meta, vars)
vars.date = vars.date or os.date '%B %e, %Y'
return body, vars
end
Closes: #6731
API changes:
- The function T.P.Filter.applyFilters now takes a filter
environment of type `Environment`, instead of a ReaderOptions value.
The `Environment` type is exported from `T.P.Filter` and allows to
combine ReaderOptions and WriterOptions in a single value.
- Global, exported from T.P.Lua, has a new type constructor
`PANDOC_WRITER_OPTIONS`.
Closes: #5221
The function `pandoc.read` is updated to use the same state that was
used while parsing the main input files. This ensures that log messages
are preserved and that images embedded in the input are added to the
mediabag.
Affiliations were `xlink`ed even in the articleauthoring tag set, but
`<aff>` are not allowed as children of `contrib-group` elements in that
tag set. Each affiliation must be listed directly in the contrib
element.
The function behaves like the default `type` function from Lua's
standard library, but is aware of pandoc userdata types. A typical
use-case would be to determine the type of a metadata value.
The objects now also follow the principle that element attributes are
accessible through the `.attr` field. Rows in `TableHead` and
`TableFoot` are available via the `.rows` field. Row objects have a
`.cells` field, containing the list of table cells.
Closes: #7718
The traversal order of filters can now be selected by setting the key
`traverse` of the filter to either `'topdown'` or `'typewise'`; the
default remains `'typewise'`.
Topdown traversals can be cut short by returning `false` as a second
value from the filter function. No child-element of the returned element
is processed in that case.
Retry conversion by passing a string instead of sources when the
`Reader` fails with a message that hints at an outdated function. A
deprecation notice is reported in that case.
The first argument passed to Lua `Reader` functions is no longer a plain
string but a richer data structure. The structure can easily be
converted to a string by applying `tostring`, but is also a list with
elements that contain each the *text* and *name* of each input source as
a property of the respective name.
A small example is added to the custom reader documentation, showcasing
its use in a reader that creates a syntax-highlighted code block for
each source code file passed as input.
Existing readers must be updated.
- `walk` methods are added to `Block` and `Inline` values; the methods
are similar to `pandoc.utils.walk_block` and
`pandoc.utils.walk_inline`, but apply to filter also to the element
itself, and therefore return a list of element instead of a single
element.
- Functions of name `Doc` are no longer accepted as alternatives for
`Pandoc` filter functions. This functionality was undocumented.