Page MenuHomePhabricator

Update to MathJax v4
Closed, ResolvedPublic

Description

Some current rendering bugs (such as the rendering of \grave a have been fixed in the latest MathJax 4.0.0 release.

There are a few things to consider

  • foreign-resources.cdx.json somehow seems to describe MathJax; however, I didn't find documentation on how this file was generated, or how it can be updated. Maybe @Tgr can help. While updating the file without knowing details, I am unsure how to change
	"serialNumber": "urn:uuid:0c9fa6df-5626-4066-bff7-665db89c0865",
	"version": 1,
  • custom helper functions need to be updated, see for example T375932

Details

Related Changes in Gerrit:

Event Timeline

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

[mediawiki/extensions/Math@master] WIP: MathJax4

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

@FrederikHennecke1 do you have a test case for the a tag rewrite?

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/1201204/2/modules/ext.math.mathjax.js

I get the impression that MathJax now supports links with a tags as well? If that were the case, we could entirely drop that workaround.

The current MathML looks like:

<math xmlns="http://www.w3.org/1998/Math/MathML" class="mwe-math-element mwe-math-element-inline">
    <mrow data-mjx-texclass="ORD">
        <mstyle displaystyle="true" scriptlevel="0">
            <mi>
                <a href="https://en.wikipedia.org/wiki/Energy" title="energy">E</a>
            </mi>
            <mo stretchy="false">=</mo>
            <mi>
                <a href="https://en.wikipedia.org/wiki/Mass" title="mass">m</a>
            </mi>
            <msup>
                <mi>
                    <a href="https://en.wikipedia.org/wiki/Speed_of_light" title="speed of light in vacuum"></a>
                </mi>
                <mrow data-mjx-texclass="ORD">
                    <mn>2</mn>
                </mrow>
            </msup>
        </mstyle>
    </mrow>
</math>

foreign-resources.cdx.json somehow seems to describe MathJax; however, I didn't find documentation on how this file was generated, or how it can be updated

See manageForeignResources.php and its make-cdx option.

See manageForeignResources.php and its make-cdx option.

Thank you, that was easy.

Physikerwelt updated the task description. (Show Details)
Physikerwelt moved this task from Inbox to Code Review on the Math board.

I did a visual regression test and I noticed two issues:

First, the symbols for \Sampi and \Stigma were both changed. I am unsure if these changes are desired.

Screenshot From 2025-11-14 02-22-50.png (600×1 px, 61 KB)

And the second, and probably more important, issue is that the symbol of \surd got moved down quite a bit.

Screenshot From 2025-11-14 02-24-36.png (294×1 px, 42 KB)

Both these issues are in Firefox and Chrome.

I did a visual regression test and I noticed two issues:

That's cool. How did you do that?

First, the symbols for \Sampi and \Stigma were both changed. I am unsure if these changes are desired.

No

And the second, and probably more important, issue is that the symbol of \surd got moved down quite a bit.

The second sample also suffers from a very small 3 in \sqrt[3]x, which may be related.

https://tex.stackexchange.com/questions/694490/placement-of-surd-with-unicode-math-is-incorrect suggests a font-related issue

Adding

window.MathJax = {
	output: {
		font: 'mathjax-tex'
	},

seems to fix the surd baseline problem.

MathML (Firefox):

Screenshot 2025-11-14 at 07.01.04.png (866×842 px, 124 KB)

MathJax 4 with traditional tex font:

Screenshot 2025-11-14 at 06.59.49.png (866×842 px, 126 KB)

I found one problem with the new font:

Screenshot From 2025-11-14 14-41-00.png (274×1 px, 35 KB)

\big and \Big now have the same size. This issue is only with the new font and on both Firefox and Chromium.
Everything else looks good to me with the new font.

Change #1201204 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Update MathJax to version 4.0.0

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