Search code examples
htmlmathml

MathML <mo> tag wrapping a decimal point


I'm using a MathML editor built into our Learning Management System (LMS) and noticed something peculiar. When I enter floating point numbers, it wraps the decimal point with an <mo> tag.

For example, I would expect 1.2 to output as:

<mn>1.2</mn>

However, the editor outputs:

<mn>1</mn>
<mo>.</mo>
<mn>2</mn>

I'm curious if anyone can confirm that both of these outputs are either equal or not equal so that I know whether or not to request a fix.


Solution

  • There are a couple of aspects, I think.

    Will they visually render the same?

    No. Most renderers will add space around the period because the MathML operator dictionary specifies . as an infix operator.

    What's the preferred way of writing 1.2 in MathML.

    Yes. <mn>1.2</mn>. See the mn examples in the spec.

    Are they semantically the same?

    That's probably a matter of opinion. I would argue that they're not. With the smallest bit of context (e.g., lang=en somewhere), it's quite clear what <mn>1.2</mn> means, while <mn>1</mn><mo>.</mo><mn>2</mn> is more generic (especially, since it's going against the spec's suggestions).

    Will AT render them the same for non-visual users?

    No. For example MathPlayer (what JAWS, NVDA, Dolphin use) will voice <mn>1.2</mn> as "one point two" and <mn>1</mn><mo>.</mo><mn>2</mn> as "one dot two". ChromeVox will voice the latter as "one period two".