User talk:Rupert/Maths Rendering
The pathway down the left of the diagram is the normal way of rendering maths in MediaWiki, and this is how I set about doing it. As well as LaTeX, GhostScript and ImageMagick, I had to compile texvc, which is bundled with MediaWiki. This required downloading and compiling an OCaml compiler, which I managed.
The first problem was with ImageMagick, which contrary to all expectation compiled without incident, but absolutely refused to find its own libraries unless run from within its own directory.
Not to worry. I was able to bypass GhostScript and ImageMagick with dvipng, although it didn't compile without a fight - I had to install freetype, and then give up on the latest version anyway. Dvipng has been used in MediaWiki before, is more efficient and does transparency better. Unfortunately, I then found out texvc was in the process of validating the TeX code, was buggering bits of it up - newlines for example. Now, I don't understand how this could be as texvc hasn't changed for ages and it obviously works on Wikipedia. But there we go.
I have removed the code from the parser which specially handles <math> tags, so now they can be handled by an extension, which makes updating or changing much easier. If maths had been added to MediaWiki after extensions, it would have been added as an extension, so I've actually been able to simplify the parser somewhat, and I intend to send this patch to the good folks at Wikimedia.
I installed wikiTeX, but it farms all the execution out to a shell script, which didn't work. I don't know how to debug shell scripts so that was the end of that.
Consequently I have written my own extension called math_lite, which displays maths as PNG files only, saving them for future use and is written keeping in mind ease of troubleshooting and with systems like ours where you don't have root access and you don't have all the programs you might like in your path. However, it doesn't return HTML for simple cases, and it's not as secure as texvc, which only allows whitelisted TeX commands, but this doesn't matter as our wiki is not accessible to all. After my exams, I will probably make it validate the input, to be on the safe side.