Page MenuHomePhabricator

Not enough spacing before colon with set-builder notation (native MathML only)
Open, LowPublic

Assigned To
Authored By
Dexxor
Jan 11 2026, 9:41 AM
Project Tags
Referenced Files
F94206836: Screenshot 2026-07-17 at 13.35.10.png
Jul 17 2026, 11:42 AM
F93992543: Screenshot 2026-07-16 at 14.28.50.png
Jul 16 2026, 12:32 PM
F93986282: Screenshot 2026-07-16 at 13.51.34.png
Jul 16 2026, 11:53 AM
F93862550: Screenshot 2026-07-15 at 21.47.36.png
Jul 15 2026, 9:01 PM
F71498254: bb.png
Jan 11 2026, 9:41 AM
F71498246: c.png
Jan 11 2026, 9:41 AM

Description

Input:

<math>\{x\in\R : f(x)=0\}</math>

Choose "MathML only" in Special:Preferences → Apperance → Math. Then preview a page with the contents.

This renders with too little space before the colon character in Firefox and Chrome:

c.png (679×117 px, 13 KB)

Server-side SVG and client-side MathJax look good:

bb.png (679×84 px, 7 KB)

This is the MathML generated for the colon character:

<mo stretchy="false">:</mo>

For comparison, https://temml.org/ generates

<mo lspace="0.2222em" rspace="0.2222em">:</mo>

and https://latexml.mathweb.org/editor generates

<mo lspace="0.278em" rspace="0.278em">:</mo>

For other problems with space around colons, see T375974 and T401746.

Event Timeline

Change #1225149 had a related patch set uploaded (by Aarohisharma3; author: Aarohisharma3):

[mediawiki/extensions/Math@master] Add explicit spacing for colon operator in MathML

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

I've fixed the MathML colon spacing issue by adding explicit lspace and rspace attributes (0.278em) to the colon operator when rendered in native MathML.

patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/1225149

Changes made:

Modified BaseMethods::checkAndParseOperator() to add spacing attributes for colon operator
Added test case testColonSpacing() to verify the fix
Testing completed:

✅ All existing tests pass (22 LiteralTest + 35 MML mapping tests)
✅ Verified with set-builder notation examples: \{x \in \mathbb{R} : f(x)=0\}
✅ MathML output: <mo lspace="0.278em" rspace="0.278em" stretchy="false">:</mo>
The spacing value of 0.278em matches the MathML standard for medium mathematical space around relational operators, ensuring consistent rendering with LaTeXML and mathml.org reference implementations.

@Aarohisharma3 Can you ensure that the colon in <math>A{:}B</math> is translated to <mo lspace="0em" rspace="0em">:</mo> and rendered without spacing? While you're at it, you might also want to fix T401746.

Thanks for the review!
I’ve updated the patch to ensure that <math>A{:}B</math> generates <mo lspace="0em" rspace="0em">:</mo> without extra spacing.
I’ll now take a look at T401746 as well.

Change #1229136 had a related patch set uploaded (by Aarohisharma3; author: Aarohisharma3):

[mediawiki/extensions/Math@master] Document `:` operator spacing with MathJax/TeX origins

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

Change #1229138 had a related patch set uploaded (by Aarohisharma3; author: Aarohisharma3):

[mediawiki/extensions/Math@master] Add PHPUnit tests for operator spacing refactoring

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

Change #1229136 abandoned by Aarohisharma3:

[mediawiki/extensions/Math@master] Document `:` operator spacing with MathJax/TeX origins

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

Change #1229138 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/extensions/Math@master] Add PHPUnit tests for operator spacing refactoring

Reason:

This is a copy of I80de68a, patchset 7.

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

Change #1225149 abandoned by Physikerwelt:

[mediawiki/extensions/Math@master] Refactor colon operator spacing to use JSON configuration

Reason:

Please look at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/1229603 which is almost done.

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

Krinkle subscribed.

Looks like this case may require a separate change from T418627, unless we leave it as a browser bug rather than something we work around.

Screenshot 2026-07-15 at 21.47.36.png (1,049×465 px, 94 KB)

Firefox and Chrome both still lack a space before the colon. Safari has a bit more spacing but it's not exactly a clear separation there either.

Physikerwelt triaged this task as Medium priority.
Physikerwelt subscribed.

Screenshot 2026-07-16 at 13.51.34.png (170×169 px, 11 KB)

It seems to work with \colon (but not with :

In MathML (without MathJax), both variants render identically and correctly.

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

[mediawiki/extensions/Math@master] Render : like \colon

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

Physikerwelt changed the task status from Open to In Progress.Jul 16 2026, 12:32 PM
Physikerwelt moved this task from Inbox to Code Review on the Math board.

Screenshot 2026-07-16 at 14.28.50.png (184×217 px, 13 KB)

suggested fix

@Physikerwelt Hm.. that looks like it goes in the other direction? The task description suggests the space was good and we want it for both. Now it looks like both are without the space?

Physikerwelt lowered the priority of this task from Medium to Low.Jul 17 2026, 11:42 AM

@Krinkle indeed. However, you did reopen the task. What do you currently see here https://www.mediawiki.org/wiki/Extension:Math/T414276

Screenshot 2026-07-17 at 13.35.10.png (339×225 px, 23 KB)

For me, it seems that MathJax and SVG render identically. This is my current focus.

For the native mode, my feeling from the MathWG engagement is that browser implementation details might change once the MathML core standard advances to the next level. As we have now introduced the HTML < a> element as a synonym for <mrow>, I think the most pressing open issue is resolved, and we can focus on spacing in native. However, I think we should treat all spacing in native at the same time for efficiency reasons.

Physikerwelt changed the task status from In Progress to Open.Jul 17 2026, 11:42 AM

Change #1311450 abandoned by Physikerwelt:

[mediawiki/extensions/Math@master] Render : like \colon

Reason:

sorry, : renders as intended in mathjax mode

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

Yep, it's specific to MathML. I never doubted the MathJax rendering. Low priority is fine.

For this particular problem, the spec has changed. In MathML 2 it was

":"                                  form="infix"    lspace="thickmathspace" rspace="thickmathspace"

https://www.w3.org/TR/MathML2/appendixf.html
whereis in MathML core it is

U+003A	block	infix	0	0.16666666666666666em	N/A

https://www.w3.org/TR/mathml-core/#operator-dictionary-human

In MathML 3 it was

: 	: 	colon 	infix 	100 	1 	2

https://www.w3.org/TR/MathML/appendixc.html

If we were to just overwrite all, to always use larger lspace=rspace, we might create problems elsewhere.

In LaTeX, the colon made by ":" is supposed to be a "mathematical relation" symbol. The spacing before and after must be the same as for other mathematical relation symbols like =, >, ≥, or →. This is subtly different than the spacing used for binary operation symbols like +, −, ·, or ×. The two types (mathrel vs. mathbin) also behave differently in different contexts.

This type of issue should not be fixed by special-casing colons per se, but instead by making sure that a LaTeX symbol of any class has the correct spacing when placed next to a LaTeX symbol of any other class. The class of symbol can be explicitly overridden in LaTeX, so that e.g. \mathbin{:} needs to behave the same way as +, and \mathpunct{:} needs to behave the same way as ,, and \mathclose{:} needs to behave the same way as ).

A test needs to be set up for every combination of two classes of symbol placed next to each-other, and the spacing should be the same as the results in LaTeX, in its default configuration with basic AMS math packages included, running offline. For the most part the MathJax-based "server-side SVG" mode handles these correctly, but for a proper test, compare to LaTeX per se.

Currently, the MathML and client-side SVG modes are both extremely broken in the way they handle spacing between various combinations of symbols of explicitly overriden class, and also pretty broken in the way they handle many combinations of symbols whose class is only implicitly specified. Fixing that is a hard requirement before any math rendering change can be deployed to English Wikipedia.

Krinkle renamed this task from Not enough spacing before colon in MathML with set-builder notation to Not enough spacing before colon with set-builder notation (native MathML only).Sep 15 2026, 2:29 PM
Krinkle updated the task description. (Show Details)
Krinkle unsubscribed.