pylatexenc icon indicating copy to clipboard operation
pylatexenc copied to clipboard

adapt LatexWalker context while walking

Open nschloe opened this issue 2 years ago • 1 comments

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]newcommands 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.)

nschloe avatar Feb 25 '22 21:02 nschloe

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.

phfaist avatar Sep 17 '22 14:09 phfaist