Reputation: 30684
I'm trying to transfer some maths content from and old wiki to my new MediaWiki.
The old page uses MathJax, and looks like this:
Here is the k-degree Taylor series for [[$ f(x) $]]
expanding around [[$ x=0 $]]
[[$ T_k(x) = f(0) + x\cdot f'(0) + \frac{x^2}{2!} f''(0) + \dots
+ \frac{x^k}{k!} f^k(0) $]]
This is what I've found so far:
http://www.mediawiki.org/wiki/Extension:MathJax -- appears to be discontinued.
http://www.mediawiki.org/wiki/Extension:SimpleMathJax -- I tried this and it works on OSX Chrome but gives rendering errors on OSX FireFox (https://github.com/jmnote/SimpleMathJax/issues/1)
http://www.mediawiki.org/wiki/Extension:Math -- this appears to be where the active development is occurring, but I haven't managed to get it working. Also it is a huge headache.
Have I missed anything?
What's the right way to enable maths content in a MediaWiki?
From what I can see, it is looking like: "render on server and provide PNG is faster, render on client using MathJax is simpler/cleaner"
SimpleMathJax is an absolutely minimal install. If only it worked on Firefox!
Math extension is looking like hard work, it looks like overkill -- it seems to support at least 4 different techniques for rendering.
Upvotes: 2
Views: 2424
Reputation: 311
A year after, the situation is getting even more confusing about how MediaWiki sites could process maths. If we all agree that texvc and maths formula displayed in png images are ugly and obsolete, it seems that Mathoid, according to https://www.mediawiki.org/wiki/Extension:Math, "is the most recommended option; Mathoid is the rendering mode that will be used on Wikipedia in the future.” .
But Mathoid requires an external server like Parsoid and they both (Mathoid and Parsoid) are in an heavy development. Therefore I looked for an other solution and found and tested successfully 'SimpleMathJax' (https://www.mediawiki.org/wiki/Extension:SimpleMathJax). It can be set like below
wfLoadExtension( 'SimpleMathJax' );
// MediaWiki 1.24 or earlier
// require_once "$IP/extensions/SimpleMathJax/SimpleMathJax.php";
works on any recent version of MediaWiki (latest version tested is mw1.28 of late December 2016).
However the code of the extension itself is not distributed with the numerous MediaWiki extensions from the WikiMedia fundation (which supports mathoid) but you can get it on github at https://github.com/jmnote/SimpleMathJax/archive/master.zip and expand it into your extension subdirectory with other extensions.
It is called "simple" MathJax probably because it doesn't have the ambition of the MW MathJax extension to process all LaTeX and TeX facilities like numbering equations and process TeX macros, but it uses the original javascript CDN of mathjax.org and therefore is very simple to install and to use for short mathematical texts. - If you want to process longer and even huge mathematical texts, you can try 'pandoc' which will transform your full LaTeX document into mediawiki source with the following command line:
$ pandoc -o foo.wiki -f latex -t mediawiki foo.tex
Upvotes: 2
Reputation: 7824
You do really want https://www.mediawiki.org/wiki/Extension:Math it is the standard way of doing things.
Maths rendering has been a problem on wikipedia for a long time now. The original system uses PNG images dates back to about 2005. It was the best that was available then, but it is really ugly, the font sizes don't match, the base line are all wrong and there is no anti-aliasing. The advantage is that its stable and works for all browsers.
Ever since then there has been attempts to improve the maths rendering. The first attempt was Blahtex which produced MathML but never got traction with the developers.
Then MathJax came along. The first implementation was as a user script https://en.wikipedia.org/wiki/User:Nageh/mathJax this worked pretty well but needed the user to manually add it to their javascript skin files.
A couple of years ago MathJax got rolled into the main Math extension, with a user preference (off by default).
MathJax is the nicest current rendering but there are two major problems, browser support, it has to work on all possible browsers including the more limited ones on phones and ancient systems. The other is speed, as it is rendered by javascript it takes time to format the equations, this can be up to a minute for the more complex formula rich pages.
MathML is another possible option, however Firefox is the only browser with halfway decent support.
This has led to a problem with making a universal system. The current development is a system which allows client side MathJax/MathML rendering for those who want the best rendering, the old PNG rendering as a fallback and a new system which uses MathJax to render SVG on the server side.
As to what to actually do. I think the simplest is to ignore extensions completely and just use MathJax on the global javascript files. See https://en.wikipedia.org/wiki/Wikipedia:Common.js_and_common.css. This would be a pretty standard MathJax configuration.
Lets look at how the User:Nageh/mathJax script works, and adapt this for your setting. What he did is install a copy of mathjax on the webserver server, in his case it was all installed in his user space https://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=Nageh%2FmathJax&namespace=2 If you have access to the server you could install the code in a more sensible place. Say for sake of argument MediaWiki/includes/MathJax. Then in common.js just have a line
importScript("/MediaWiki/includes/MathJax/MathJax.js");
or possible better
mw.loader.load("/MediaWiki/includes/MathJax/MathJax.js");
or even better
mw.loader.using("/MediaWiki/includes/MathJax/MathJax.js").done( function() {
MathJax.Hub.Config( ... );
} );
after than just have the MathJax hub setup you need. See https://www.mediawiki.org/wiki/ResourceLoader for details.
Upvotes: 2