-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: MathML combines multidigit numbers with sup/subscript, comma separators, and multicharacter text when outputting to DOM #3999
Conversation
The code written above will split a number like "4,200.30" into two elements, split at the comma. It will also mangle an expression like In Temml, I struggled a bit and ended up with a more complex solution. My approach modified only the
Elsewhere in the same file, I added this code:
It's quite possible that parts of both solutions could be combined to form a solution that is less verbose than the Temml version, but still is correct. |
@ronkok Wondering if your solution caters for European number style, with periods and commas reversed, so 1.234,5, or with spaces, like 10 000,45? |
I haven't grokked your code yet, but I'm a little confused about the goal. In LaTeX you need to write These heuristics feel a little messy, but it seems they're necessary for going from presentation to semantics. I also don't think they're especially related to this PR. Do you agree that the change in this PR is useful, independent of how the nodes get combined? |
@mbourne The European number style was a major motivation for how I wrote this code. @edemaine I take your point about TeX requiring a |
I agree. I'd like to find code that is less verbose. I haven't found it yet.
It is certainly better than the status quo. I would suggest at least examining the following atom to see if it a |
@ronkok I've taken a stab at handling |
Good stuff! I haven't looked at the code yet, but the preview shows me that you have:
I hate to move the goal posts at this late date, but I have just now realized there is another problem. In the expression |
Thanks for reviewing!
Yep, exactly.
I believe that that is actually correct: here's how it renders in HTML. So the MathML correctly reflects the same.
|
Ah yes, you're correct. Which means that all the behavior I see from this code is good. I don't plan to do a detailed review of code style, but I think it looks good in general. |
🎉 This PR is included in version 0.16.17 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What is the previous behavior before this PR?
When rendering MathML directly to the DOM (as opposed to a string), such as on the katex.org front-page demo, consecutive digits and text characters get rendered as multiple text children of an
<mn>
or<mtext>
elements:What is the new behavior after this PR?
When rendering MathML directly to the DOM, we combine consecutive text children into one:
Fixes #3995 which reports that this causes screen-reading issues.
Merging of consecutive
<mtext>
and<mn>
elements is already done here:KaTeX/src/buildMathML.js
Lines 157 to 167 in 2d1fec9
And when rendering to a string, this was enough. Indeed, we don't have a great way of testing this, without a virtual DOM setup. But the inspect screenshots above confirm that this PR fixes the issue.