pylatexenc
pylatexenc copied to clipboard
adapt LatexWalker context while walking
One can adapt the LaTeX contet (how to parse macros, environments etc.) with
w = LatexWalker(self.string, latex_context=latex_context)
This, however is not how LaTeX works. Macro names can take different meaning throughout the document, depending on what \[re]newcommand
s appear. I would hence suggest to add a mechanism to adapt the walker context while walking through it. This implies that the walker only ever decodes the next keyword, not the whole document at once.
(Perhaps there already is a way to handle this and I've missed it.)
There is an undocumented way to handle state changes in pylatexenc 2, and there will be an official way of doing that in the upcoming pylatexenc 3.