belerico / py_asciimath

A simple converter from ASCIIMath to LaTeX or MathML and from MathML to LaTeX
MIT License
38 stars 10 forks source link

TeX to ASCIImath \frac error #14

Open Lyudol opened 1 year ago

Lyudol commented 1 year ago

When running this code:

from py_asciimath.translator.translator import (
    ASCIIMath2MathML,
    ASCIIMath2Tex,
    MathML2Tex,
    Tex2ASCIIMath
)

latex_input = r"\frac{3}{2^4}"
tex2asciimath = Tex2ASCIIMath(log=False, inplace=True)
parsed = tex2asciimath.translate(latex_input, from_file=False, pprint=False,)
print(parsed)

prints this:

frac(3)((2)^(4))

when it's meant to print:

(3)/(2^4)

Is there something wrong with how the LaTeX equation is being input or is it a bug?

belerico commented 1 year ago

Hi @Lyudol and sorry for the late response. It's been a long since i haven't done something on this repo :smiling_face_with_tear:. I don't think there's a bug in there, i think that is not optimized to reduce the unneeded parentheses; but, for the reason above, i can also be wrong.