Page MenuHomePhabricator

Bad kerning of decimal separator in MathML
Closed, ResolvedPublicBUG REPORT

Description

Enable "Client side MathJax rendering" in Special:Preferences → Apperance → Math. Then preview a page with the contents <math>0.99</math>. There is too much space around the decimal separator.

This is because in the generated MathML every digit is put inside its own <mn> element and the decimal separator is put inside <mo>:

<mn>0</mn>
<mo stretchy="false">.</mo>
<mn>9</mn>
<mn>9</mn>

This is bad as the number 0.99 is a single semantic token. https://temml.org/ generates <mn>0.99</mn> instead.

Also see T390260

Event Timeline

Change #1189628 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] WIP: MathJax spacing of numbers

https://gerrit.wikimedia.org/r/1189628

With the patch above <math>0.99</math> also generates <mn>0.99</mn>. The regexp for merging is /[0-9.]/. Please let me know if that should be extended to other decimal-separators.

On dewiki, it's common to use {,} as decimal seperator, e.g. 3{,}14. Support for that would be nice as well.

Ok, it works in TeX. However, it does not seem to make a difference for either mathoid, Temml, or LaTeXML if curly braces are used or not.

Change #1189970 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] Handle comma as decimal separator

https://gerrit.wikimedia.org/r/1189970

On dewiki, it's common to use {,} as decimal seperator, e.g. 3{,}14. Support for that would be nice as well.

This works now as well. However, I excluded {,}99' and 0,99`. As I was unsure if {,} might have a different meaning in some situations, for example, within mhchem.

Is that OK?

I don't fully understand what you excluded, but dewiki never uses numbers without a leading digit so while .99 (point nine nine) should be squashed, it's OK if {,}99 isn't.

Change #1189628 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Squash numbers in TexArray

https://gerrit.wikimedia.org/r/1189628

Change #1189970 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Handle comma as decimal separator

https://gerrit.wikimedia.org/r/1189970