Page MenuHomePhabricator

Verify visual parity between mathoid and mathml+mathjax via parsoid visual diff tests
Open, Needs TriagePublic

Description

Event Timeline

Decide if the main pagelist used by Parsoid contains enough representative Math formulas, or whether to use a separate pagelist.

Where can the pagelist be accessed?

It should contain something like https://en.wikipedia.beta.wmcloud.org/wiki/Help:MathTestNative

@Krinkle I don't understand what I need to do here.

MSantos renamed this task from Verify visual parity between mathoid and mathml+mathjax via parsoid-rt-tests to Verify visual parity between mathoid and mathml+mathjax via parsoid visual diff tests.Thu, Jul 23, 2:16 PM
MSantos updated the task description. (Show Details)
ihurbain subscribed.

I'll run a visualdiff on https://en.wikipedia.beta.wmcloud.org/wiki/Help:MathTestNative and we'll see where we're at (this looks pretty comprehensive).

Okay, I have run said visualdiff. It's not catastrophic and significantly better than mathml rendered by the browser, BUT I wouldn't call it parity.

In particular, and without being entirely sure if something there depends on my own setup (in particular fonts):

  • the fonts are overall lighter/greyer
  • the norm signs are more compact
  • \prime and \backprime are superscript rather than on the line when they're on their own
  • \pmod has less space before it
  • \backslash is not consistent with /
  • \varnothing is the same symbol as \emptyset
  • \setminus and \smallsetminus are not distinguishable from oneanother
  • arrays rendering do not display horizontal / vertical lines
  • \cdots / \vdots \ ddots are more compact (which I believe is the main reason for the bmatrix of the example to be smaller)
  • the boldface greek is bold AND italic

The PNGs are too large to attach to this phab, but I have them around if someone else wants to have a look at it.

From what I see this is MOSTLY useable, but ideally we'd be able to fix the elements I'm listing here.

I don't think fonts should affect mathjax. My understanding is that mathjax implements the compatibility layer (including fonts).

As I understand it:

  • in mathoid mode, we send the TeX directly to mathoid and let it do its thing (as I understand it: ship it to mathjax, which handles the full TeX->MathML->SVG conversion)
  • in mathjax mode, we convert the TeX to MathML, and that's what we ship to mathjax-client-side.

From what I can see, the diffs are due to diffs from the TeX->MathML conversion (for instance, $\backslash$ is mapped to in src/WikiTexVC/texutil.json, which explains the discrepancy between this and / on the sample page.

I believe this would be better handled by folks closer to the "rendering math" side of the extension; I'm also assuming that we might not want exactly the same conversion for "send MathML for the browser to be interpreted" and "send MathML for MathJax to interpret". I expect that @Physikerwelt has more informed opinions than I do on the matter.

We've merged a patch this week for T433928 which makes "parsing math pages in different modes" work without requiring purging the page cache between parses, which should make checking and diffing easier; let us know if we can support you to improve parity before we shut down Mathoid.

As I understand it:

  • in mathoid mode, we send the TeX directly to mathoid and let it do its thing (as I understand it: ship it to mathjax, which handles the full TeX->MathML->SVG conversion)
  • in mathjax mode, we convert the TeX to MathML, and that's what we ship to mathjax-client-side.

[…] I'm also assuming that we might not want exactly the same conversion for "send MathML for the browser to be interpreted" and "send MathML for MathJax to interpret". […]

The extension offers four modes:

  • source: raw LaTeX
  • mathml: MathML and SVG from server-side MathJax (Mathoid: <span style="display: none;"><math>..</math></span><img src=..>).
  • native: MathML only (MediaWiki PHP: <math>)
  • mathjax: MathML and SVG from client-side MathJax (MediaWiki PHP: <math>, JS: => <svg>).

We are transitioning from SVG from MathJax server (Mathoid aka mathmode=mathml), to SVG from MathJax client (aka mathmode=mathjax).

Note that https://en.wikipedia.beta.wmcloud.org/wiki/Help:MathTestNative is a copy of https://en.wikipedia.beta.wmcloud.org/wiki/Help:MathTest that forces mathmode=native in the wikitext. We don't need to test the native mode, because this is not expected to be visually identical, has known differences, and is not what we're moving to as the new default.

I apologize for the confusing history around Mathoid mode being called mathml, and T271001 being a transition "to MathML".

I believe we want to compare these two:

I suspect that is indeed the diff you ran, but I want to double check just in case :)

I believe we want to compare these two:

I suspect that is indeed the diff you ran, but I want to double check just in case :)

It is indeed, and worth double-checking, it took me a little while to make sure that I was doing the right thing :D

[…]

  • the boldface greek is bold AND italic
MathJax SVG (server, Mathoid)
Screenshot 2026-08-06 at 17.29.48.png (1,363×795 px, 213 KB)
MathJax SVG (client, Firefox)
Screenshot 2026-08-06 at 17.29.50.png (1,363×795 px, 223 KB)
MathJax SVG (client, Chrome)
Screenshot 2026-08-06 at 17.29.54.png (1,363×795 px, 466 KB)

I've created a bug T434428 for the capital Greek letters and a test case page https://www.mediawiki.org/wiki/Extension:Math/T434428 showing all the alphabet and type face in the three modes.

https://www.mediawiki.org/wiki/Extension:Math/Native_MathML/Operators contains side by side comparisons for all the operators.