Wrong convertion LaTEX-code to MathML
See original GitHub issueDescribe the bug: The LATEX-code are converted to MathML wrong, although by visually all OK. The correct MathML is needed to read math formulas by screen-readers.
To Reproduce: Steps to reproduce the behavior:
- Try to type the difficult LaTEX-formula which contains, for example, log or trigonometric function. My example is:
$${\log_{\sqrt{11}} 121}^2$$ - see the source MathML-code (not a visual picture of the formula).
Expected behavior:
I should get something about this:
<math> <msup ><mrow ><msub ><mi>log</mi><msqrt ><mn>11</mn></msqrt></msub><mo></mo><mn>121</mn></mrow><mn>2</mn></msup></math>
But I get such MathML:
<math ><msup ><mrow ><msub ><mo><mi>log</mi><mo>⁡</mo></mo><msqrt ><mn>11</mn></msqrt></msub><mn>121</mn></mrow><mn>2</mn></msup><mrow encoding = "application/x-tex"></mrow></math>
Environment (please complete the following information):
- KaTeX Version: latest (the problem is relevant even or your demo)
- Device: laptop, but the problem is relevant for all devices.
- OS: Windows 10, iOS 14
- Browser: Chrome, mobile safari
- Version: Chrome 86, Safari 14
Additional context:
The log and other functions shouldn’t be wrapped into <mi></mi> tags as it is interpreted incorrectly by different MathML-readers (such as MathPlayer). The wrong convertion of LaTEX-code breaks an accessibility The problems almost at all formulas with log or trigonometric functions. Also in some situations, for example, there is an excess subscript, and so on.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9

Top Related StackOverflow Question
@Futyn-Maker Thank you for the comment. I believe that this MathML can be written in more than one way and still meet the W3C spec for MathML. So we want to write the version that works in both visible browsers and in screen readers. I’ve volunteered quite a lot of time in the last year to cleaning up KaTeX’s MathML and your feedback tells me that I have some more work to do.
So here is what is going to happen next. I’m going to go work up a modification of KaTeX. Maybe a couple different versions. I’ll put the output up on a test page somewhere and then I’ll come back here, give you the URL, and ask you to tell me how they work. When we get something that works properly for all
viewersreaders, then I’ll turn in a PR to this repository.Give me a couple of days. I’ve got some other things on my plate right now.
Yes, it seem that all OK. The operator name are spoken correctly. The MathML code which generated the Access8Math addon in NVDA is following (it can bit differ of original KaTEX-code):
<math ><munder ><mrow ><mi>asin</mi><mo></mo></mrow><mi>y</mi></munder><mi>x</mi><mrow encoding = "application/x-tex"></mrow></math>Andrey