How to write a Pandoc Lua filter with a function matching all elements despite of its node type?
With a Python panflute filter I would do it as follows:
# Python filter
from panflute import *
def action(elem, doc):
debug(type(elem))
def main(doc=None):
return run_filter(action, doc=doc)
if __name__ == "__main__":
main()
With Lua I'd like to have somethig like the following:
-- Lua filter
function action(elem)
print(pandoc.utils.type(elem))
end
return {
{Inline = action},
{Block = action},
-- {* = action}, -- this is no valid Lua
-- how many types must be added here to cover all the types?
}
If every element type has to be explicitly added. Where can I get the List of all element types?
Lua filters support filtering on Inline, Block, Meta, and Pandoc elements. Thus this should work:
return {{
Block = action,
Inline = action,
Meta = action,
Pandoc = action,
}}
The docs could probably be a little clearer on that point.