Page MenuHomePhabricator

Colon in f : X \to Y should be an operator in MathML mode.
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
SalixAlba
Sep 29 2024, 12:42 PM
Referenced Files
F57711090: image.png
Nov 16 2024, 7:31 PM
F57611391: image.png
Oct 13 2024, 5:13 PM
F57611388: image.png
Oct 13 2024, 5:13 PM
F57611385: image.png
Oct 13 2024, 5:13 PM
F57594793: Screenshot 2024-10-07 at 15.20.49.png
Oct 7 2024, 1:22 PM
F57569276: image.png
Sep 29 2024, 1:22 PM
F57569165: image.png
Sep 29 2024, 12:42 PM
F57569157: image.png
Sep 29 2024, 12:42 PM

Description

Steps to replicate the issue (include links if applicable):

  • Set math mode to MathML
  • Enter the formula <math>f:X\to Y</math>

What happens?:

Generates

image.png (70×175 px, 2 KB)

With no space around the :

What should have happened instead?:

More space is common. In SVG

image.png (87×251 px, 3 KB)

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Looking at the generate MathML we have

<math class="mwe-math-element" xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow data-mjx-texclass="ORD">
    <mstyle displaystyle="true" scriptlevel="0">
      <mi>f</mi>
      <mi>:</mi>
      <mi>X</mi>
      <mo accent="false">→</mo>
      <mi>Y</mi>
    </mstyle>
  </mrow>
 </math>

The : is represented by <mi>:</mi> rather than <mo>:</mo>. Colon is included in the MathML operator directory.

Event Timeline

Going through https://en.wikipedia.org/wiki/Help:Displaying_a_formula
the following are also represented as <mi> elements.

\backslash

\angle, \sphericalangle, \measuredangle

\Box, \square, \blacksquare, \Diamond \lozenge, \blacklozenge, \bigstar

\triangle, \triangledown, \blacktriangle, \blacktriangledown

\forall, \exists, \nexists

\And

\lnot, \neg, \not\operatorname{R}, \bot, \top

\S

\diamondsuit, \heartsuit, \clubsuit, \spadesuit, \Game, \flat, \natural, \sharp

\diagup \diagdown

image.png (645×379 px, 31 KB)

As a first step, it would be good to understand when mo vs mi should be used. This is not entirely clear to me.

The W3 spec has

"An mo element represents an operator or anything that should be rendered as an operator. In general, the notational conventions for mathematical operators are quite complicated, and therefore MathML provides a relatively sophisticated mechanism for specifying the rendering behavior of an mo element. As a consequence, in MathML the list of things that should render as an operator includes a number of notations that are not mathematical operators in the ordinary sense. Besides ordinary operators with infix, prefix, or postfix forms, these include fence characters such as braces, parentheses, and absolute value bars; separators such as comma and semicolon; and mathematical accents such as a bar or tilde over a symbol. We will use the term "operator" in this chapter to refer to operators in this broad sense."

The Operator Dictionary, does explicitly list character it considers as operators. I intend to cross reference those with the above, but it will take a couple of days before I have time.

W3 has a different idea to LaTeX of what operators are, \operatorname{sn} x when sn is a function name does not correspond to a MathML operator, and the spec says this should be represented as
an identifier.

<mrow>
  <mi> sn </mi>
  <mo> &#x2061;<!--ApplyFunction--> </mo>
  <mi> x </mi>
</mrow>

So I'm kind of thinking for MathML operators are anything that is not a number or an identifier.

Would changing from mi to mo solve the problem?

I think that seem to be the correct behaviour.

Going through the list of operators in Help:Equations the disparities are

  • D \And E has more space in LaTeX but none in SVG and MathML
  • A \smile B \frown B more space in SVG
  • A \therefore B \because B more space in SVG
  • B \overset{\underset{\mathrm{def} }{} }{=} B no space in SVG space in MathML and LaTeX
  • A\ulcorner B \urcorner B \llcorner B \lrcorner C no space in SVG, space in MathML
  • A \blacktriangle B \blacktriangledown B no space in SVG, space in MathML

Examples at https://www.mediawiki.org/wiki/Extension:Math/Native_MathML/Reported_Cases number 12

MathML

image.png (423×288 px, 11 KB)

SVG

image.png (416×240 px, 17 KB)

LaTeX

image.png (526×295 px, 13 KB)

The \ulcorner, \urcorner, \llcorner, \lrcorner don't have corresponding entries in the operator directory. So should probably be identifiers. Mainspace use at https://en.wikipedia.org/wiki/Reflection_principle where there should not be space

The \blacktriangle, \blacktriangledown do have OD entries
&#x25B2; ▲ black up-pointing triangle, and &#x25BC; ▼ black down-pointing triangle. The only uses in main space are as superscripts so not a problem

\therefore, \because have more space in Firefox, so chrome is not respecting the lspace and rspace of 5.

There is no OD entry corresponding to \smile, \frown. Mainspace use in https://en.wikipedia.org/wiki/Cartan_formula

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

[mediawiki/extensions/Math@master] Treat colon as operator

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

@SalixAlba I submitted a patch for :

I also see the differences, but I'm not sure how it should be?

Maybe we file a new task with a table of the desired values?

Change #1088678 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Treat colon as operator

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

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

[mediawiki/extensions/Math@REL1_43] Treat colon as operator

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

Change #1089272 merged by jenkins-bot:

[mediawiki/extensions/Math@REL1_43] Treat colon as operator

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

Has more space now

image.png (159×162 px, 10 KB)
as it uses <mo>:</mo> instead of <mi>:</mi>. See https://en.wikipedia.beta.wmflabs.org/wiki/T375974

A lot of other problems were discussed in this ticket as well, but I think it is better to close this issue and open a new tickets for further changes.