Closed zspitz closed 3 years ago
It would have been nice to implement this, but lambda syntax has no typing in C#, so it's impossible to pass in delegates of multiple types to a single overload of Filter.Run
without explicitly typing them before.
We've defined two visitors -- RawDelegateVisitor
for raw types, and DelegateVisitor
for higher-level Pandoc types. Each visitor exposes multiple Add
overloads, which types the delegate based on the first parameter. When the visitor instance is passed into Filter.Run
, each delegate is run at the appropriate place in the tree.
Once a new tree is built inside the delegate and returned, the visitor will visit the new tree, not the old one.
For an example, see the Sample section on the README.
Instead of writing an entire visitor class, we could have an overload that takes one or more delegates, each with a single parameter.
The type to be processed would be determined by the parameter type. For example:
would be applied to all blocks, using an internal visitor.
Question: should these delegates be allowed to visit children? That would require the visitor as the second parameter.