Atreyagaurav / litex-mode

LiTeX mode for emacs; A minor mode to convert valid lisp expressions to LaTeX
GNU General Public License v3.0
43 stars 4 forks source link

improve brackets logic #17

Open Atreyagaurav opened 2 years ago

Atreyagaurav commented 2 years ago

Right now brackets logic is kinda funky. I recently noticed it was broken, (I need to put ert tests in CI soon).

Right now the logic is spread between the functions as well as inside a function to detect, a way to make it completely modular and hopefully working well.

Modify the litex-maybe-enclose function to also read which function it was called from, and then make appropriate judgement based on function name and arguments.

Atreyagaurav commented 2 years ago

This is really hard to generalize, Just realized that there is error of double superscript when the number is formatted as 2 × 10² format and is inside the exponential function.

(expt 2e5 2)2.000 \times 10^{5}^{2}, which is invalid expression for latex.

So, For now brackets were added only for expressions, and now I might have to consider values as well, which complicates things. Feels like I might have to make different representations for the sexp that are to be converted to latex instead of trying to convert it directly to latex.

It already adds too many brackets to make sure it doesn't miss any, and now this...