849900c516
Attribute lists are represented as associative lists in Lua. Pure associative lists are awkward to work with. A metatable is attached to attribute lists, allowing to access and use the associative list as if the attributes were stored in as normal key-value pair in table. Note that this changes the way `pairs` works on attribute lists. Instead of producing integer keys and two-element tables, the resulting iterator function now returns the key and value of those pairs. Use `ipairs` to get the old behavior. Warning: the new iteration mechanism only works if pandoc has been compiled with Lua 5.2 or later (current default: 5.3). The `pandoc.Attr` function is altered to allow passing attributes as key-values in a normal table. This is more convenient than having to construct the associative list which is used internally. Closes #4071
6 lines
174 B
Lua
6 lines
174 B
Lua
function Div (div)
|
|
div.attributes.five = ("%d"):format(div.attributes.two + div.attributes.three)
|
|
div.attributes.two = nil
|
|
div.attributes.one = "eins"
|
|
return div
|
|
end
|