Page MenuHomePhabricator

API does not list ResourceLoader Mathjax module when needed
Closed, ResolvedPublic

Description

It is difficult to scrape proofwiki.org with MWoffliner because the wiki pages require ResourceLoader module ext.mathJax but this module is not listed in by the API call https://proofwiki.org/w/api.php?action=parse&format=json&useskin=vector&prop=modules|jsconfigvars|headhtml&page=Definition%3AThomae%20Function.

First detected in https://github.com/openzim/mwoffliner/issues/1371

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I can't find any code in Codesearch that relates to a ext.mathJax module. Which extension is responsible for that? Is that extension open-source and hosted on Gerrit, or elsewhere?

This is most likely a problem in the extension and not with ResourceLoader, however I'm happy help investigate and work with the extension maintainer to pinpoint and fix the problem.

Krinkle moved this task from Inbox to External on the MediaWiki-ResourceLoader board.

Untagging "API-Gateway", which is a different API.
Untagging "Math" as thats about the "Math" extension, which does not seem to have a module called ext.mathJax.

@Krinkle I thought first from https://proofwiki.org/wiki/Special:Version that it was https://www.mediawiki.org/wiki/Extension:MathJax... but now I have a big doubt.

Yeah, that extension has no module currently named ext.mathJax.

@Krinkle I have mailed someone at Proofwiki and it was given to me the following link (seems to be and older Version of the MathJax extension) https://www.mediawiki.org/w/index.php?title=Extension:MathJax&oldid=1184913. Not sure what would be the next step. Would that simply work if they update the extension to the latest version?

@Kelson Perhaps. Although it seems the extension is incompatible with its former self, and would require Proofwiki to have most of its pages modified to use the newer syntax. I don't know much about MathJax, but it seems Proofwiki articles don't use the <math> tags to demarcate its formulas, but instead use the loose $…$ syntax. And the latest version of MathJax (commit seems to have removed this functionality.

More generally it is not a very well-maintained extension, and probably still wouldn't work well with Kiwix. It would need to use $parser->addModules() instead of $wgOut->addModules() and such. That's probably an easy fix, and perhaps something Proofwiki would be willing to apply as a patch to their outdated copy of MathJax.

My recommendation would be to stop using this unmaintained and possibly unsafe alternative to the Math extension and use that instead. However that, too, would require updating of articles to use new syntax. Perhaps it would be easy with a bot, or perhaps there are other subtle differences that motivated creation of these alternatives. I'm not sure.

Ultimately though for Kiwix's purposes, all that matters is that modules are queued by calling methods on the relevant Parser or ParserOutput object like $parser->addModules(), $parser->addModuleStyles(), and $parser->addJsConfigVars(). Older extensions often called similar methods on the OutputPage object like $wgOut which means the modules were lost if the page was cached instead of freshly paged (since the code doesn't re-run), and also lost when requested via the API.

Gilles claimed this task.

@Krinkle Thx, I'm still in touch with a developer of this custom version of MathJax extension and he will try to load the MathJax js code within the ResourceLoader.