Closed sammarshallou closed 12 years ago
Robert says:
"I add a pre-processing step that looks for math mode starting with ^ or _ and if it is found then it adds braces to the start of the equation (as this works and is harmless)."
Sounds like a plan.
Added comments:
I believe that your mathML generator may also struggle with $anything{^2}$ as the state of the generator at the start of a braced expression is the same as the state at the start of an equation.
[...]
Returning to the original bug. The fix is easy, adding one line and modifying two others (as I mentioned I have added it to the post347 repository). The added line was to define the \strut command to be an empty mrow element:
"\strut": lambda slf: result_element(u"mrow",0)
(which is added as an entry in the g_tex_commands list of LaTeX2MathMLModule.py). This renders \strut in a way that respects the way that it is defined in TeX. Then I changed two lines to look for superscripts at the start of an equation (or the start of a braced expression which also has the same issue) so that it used \strut, the diff lines are:
#fix for superscripts without prior text
I didn't fix it in precisely the way described, but a similar one; I still inserted a \strut before the ^ or _, but I did it in the parser code which should hopefully be more reliable than using a regular expression.
The following equations do not render correctly:
^0 ^0 + x
These render as literal '^0' in MathML.