Closed flimofly closed 2 months ago
In the v3 alpha prerelease, there's a LatexNodesVisitor
class that implements the visitor design pattern and can help you out to interate through group nodes. Essentially, you should create a subclass of LatexNodesVisitor
and reimplement the methods you're interested in, such as visit_group_node()
, visit_macro_node()
, etc. To start the visitor you run visitor.start(node)
.
See https://pylatexenc.readthedocs.io/en/latest/latexnodes.nodes/#pylatexenc.latexnodes.nodes.LatexNodesVisitor (the doc isn't complete yet, sorry) and https://github.com/phfaist/pylatexenc/blob/main/pylatexenc/latexnodes/nodes.py#L1259 .
Congratulations on thank you for this magnificent tool!
I was wondering whether a recursive function is needed to parse LatexGroupNodes?
E.g.
If so, what's the best approach to avoid infinite recursion?