siefkenj / unified-latex

Utilities for parsing and manipulating LaTeX ASTs with the Unified.js framework
MIT License
91 stars 24 forks source link

Fix nested subscripts parsing #114 #117

Open postaid opened 1 month ago

postaid commented 1 month ago

Hi @siefkenj This PR should fix #114
Main change is to replace "group" with "math_group" in "math_token" section of peg latex grammar. Also add "options" param to processLatexToAstViaUnified function which allows ti use "math" mode

siefkenj commented 1 month ago

One concern of mine is that something like $x*\text{foo}$ will not get parsed correctly. Can you check that this PR still parses text inside of math correctly?

siefkenj commented 1 month ago

Thanks for the contribution! It looks like a few tests need to be fixed up.

postaid commented 4 weeks ago

Should I fix them in this PR?

siefkenj commented 4 weeks ago

Yes, please.

postaid commented 3 weeks ago

Hi @siefkenj! Add some fix to peg grammar. Add "math_shift" entity ($) to math_token parsing.

Also change text content nodes detection inside "unifiedLatexLintNoPlaintextOperators", because current implementation counting on "no math context inside groups".

siefkenj commented 3 weeks ago

This looks good so far. Can you add a test for $x_{y_{\text{hello there $p_q_r$}}}$?

postaid commented 3 weeks ago

Added the test you are asked for.

postaid commented 2 weeks ago

Got the problem finally. Add separate processing of \text macro inside math context.