Page MenuHomePhabricator

How to reconfigure MathJax to handle MathML as well as TeX, for compatibility with other extensions
Closed, ResolvedPublic

Description

I've had a complaint that my extension (WorkingWiki) and the Math extension can't both be used in the same wiki, at least not when both are configured to use MathJax. It looks like the problem is that you can either have WW configure MathJax to accept MathML input or have the Math extension configure it to accept TeX/texvc input, but not both. I've had a look in the Math code, and I don't see a straightforward way to tweak its MathJax config to get it to add MathML input to the other things it's doing. Do you think it's possible? Would I need to create an alternative to TeX-AMS-texvc_HTML.js and swap in that filename in the mathJax.config object, after the config object is created but before it's used?


Version: REL1_21-branch
Severity: normal

Details

Reference
bz58201

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:33 AM
bzimport added a project: Math.
bzimport set Reference to bz58201.

physik wrote:

Hi Lee,

I see two main problem here:
One problem is, that the Math extension uses the tag name math that causes confusion with the xml element math. I think it would be better if the math tag would be renamed to e.g. m. But I have doubts that this will find a large acceptance since the tagname math is familar to a lot of people.
In the LaTeXML mode you can use MathJax to display MathML.
See http://demo.formulasearchengine.com/ for a demo.
However, with MathJaX 2.2 we did not find a way to accept both inputs (MathML and texvc) on the same page.
I think that has improved with MathJax 2.3 but I did not try that.
Please be aware that MathJax has another (I think much easier way) to adjust the configuration.
MathJax 2.3 has already been ported to the Math extension. However, the code review process did not make any progress in the last two month, which is a little bit unfortunate. I added you as a reviewer so you can have a least a look how the things should change.

Best
Moritz

Thank you, Moritz. I don't have a problem with a conflict between the extension's math tag and the mathml element, because I'm not looking to include mathml elements in the wiki page source code, only in the HTML output that my extension produces. I only want to tell MathJax to process the mathml math element in addition to your tex inputs.

Unfortunately I also have a user who wants to use both extensions in MediaWiki 1.21, so the LaTeXML mode isn't available.

What is the easier way to adjust the MathJax configuration?

Best
Lee

physik wrote:

Lee,
Since Math2.0 produces MathML output as well the problem should no longer exist. I have just tested the old issue (with MathML and texvc on the same page) and even this problem has been resolved.

I have the impression that the configuration of MathJax is much more structured and easier to understand.
See
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FMath/c2d9ed1559a9277b8f757f36bbc44f8b0da3b5b1/modules%2Fext.math.mathjax.enabler.js#L31

jax: ['input/TeX','input/MathML','output/NativeMML','output/HTML-CSS']

For the configuration of MathJax for Math2.0 that accepts MathML and TeX input.

Best
Moritz

Thanks, Moritz!

It sounds like there may be two ways to use WW and Math together: upgrade to 1.22, and Math 1.0's mathjax configuration will handle mathml elements when it's in LaTeXML mode; or install Math 2.0 from the unmerged gerrit patch, and its mathjax will parse mathml in all Math extension modes. Does that sound right to you?

I assume Math 2.0 requires MW 1.22 or 1.23?

As another possibility, it looks to me from debugging this issue that whichever x-mathjax-config element appears first in the page is the one used. So it might be that I can have my extension insert one of those early, causing it to load mathjax 1.23 with both kinds of input enabled, and it will work with the output of the current 1.0 Math extension in MW 1.21, overriding the Math extension's mathjax config. I guess I would have to do some extra work to include the texvc processing, but since this is for non-WMF wikis, people may not care for that anyway. Do you think that would fail?

Best,
Lee

Just a comment from the MathJax side of things. MathJax will read all configurations and they will be joined up -- but values overwrite each other, so the last output config wins.

physik wrote:

Hi Lee,

there is a dependenciy to MW 1.22 if XML Checking is desired.
However not having 1.22 produces a warning only.

Mathml 2.0 seperates the texvc sanitizing and rewriting of mediawiki specific functions from the actual conversion from latex source to png images.
The output of texvccheck is normal latex output that does not require special treatment.

Best
Moritz

Great - thanks to both of you!

I'll try switching to latexml mode in 1.21 and see if it resolves the problem.

Best
Lee

Change 120486 had a related patch set uploaded by Physikerwelt:
Expiremental option MathML input

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

Change 120486 merged by jenkins-bot:
Expiremental option MathML input

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

All patches mentioned in this report are either merged or abandoned - is there more work left to do here (if yes: please reset the bug report status to NEW or ASSIGNED), or can you close this ticket as RESOLVED FIXED?