Great, thanks both of you, I get the idea, will try that. T. On Wednesday, May 10, 2023 at 5:08:06 PM UTC+2 Albert Krewinkel wrote: > > ThomasH writes: > > > is there a way to get to the parent in the Pandoc AST from the > > current element in a Lua filter? > > I would like to distinguish treatment of elements depending on their > > context in the syntax tree, e.g. handle a 'span' element differently > > if it is a child of a 'cell' element in a table. > > This is currently not supported in Lua; panflute (Python) filters do > enable that though. > > What Lua does support though is to change the order in which elements > are traversed, as well as the option to stop processing of a subtree. > See https://pandoc.org/lua-filters.html#traversal-order > > E.g., to handle all Spans in a table differently you'd use > > traverse = 'topdown' > > function Table (tbl) > return tbl:walk(my_filter_for_table_spans), false > end > > function Span (span) > -- default span processing > return span > end > > It's a bit of a brain-twister (and can be slower than normal filters) > but it enables most of the actions that one would otherwise use the > parent element for. > > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/eb2115c3-ee11-4f82-bb49-6fd423d9365fn%40googlegroups.com.