I'm looking for something equivalent to MathJax, but that does the conversion(s) from MathML or LaTeX to HTML-CSS on the server backend as my site is rendering the page, rather than relying on something client-side like a traditional install of MathJax. Ideally, this would be written in Python, but other languages or commandline tools would be acceptable as well.

There seem to be some out there (latex2html, plastex) but the output quality is much, much lower than what's produced my MathJax.

I've seen some mumblings of node.js + MathJax for this purpose, but with much grumblings from the MathJax maintainers.

Hevea is a capable (command line, not server-side) tool and its homepage doesn't do it justice. But I haven't used it for a long time and don't know how it compares to tex4ht, for example.
–
Christian LindigJun 25 '11 at 6:11

One of the nice things about MathJax is that it doesn't require LaTeX installation. But the client-side parsing is somewhat slow, especially on pages with lots of equations. I had an idea long ago to make a python version of jsmath, but when I took a peek at the source, I found that it's not going to be a trivial work.
–
syockitJan 5 '14 at 6:19

4 Answers
4

I wrote the below, then reread the question, and realised that you want to convert to HTML+CSS. I originally thought you meant to MathML or HTML+CSS and answered appropriately. However, the bit about converting from MathML to SVG might be relevant. Also, I'd strongly advise you not to convert from MathML to HTML+CSS. The right way to put maths on the web is with MathML.

(Yes, that's just my opinion ... but it happens to be the right opinion!)

Usually when people talk about "LaTeX to ?ML" then they mean "LaTeX mathematics to ?ML". I'm going to assume that you mean that. If you want a more full conversion then tex4ht is the best bet. However, tex4ht not suitable for a system where the content is generated on demand.

The server-side conversion software that I know of is itexToMML. The input format is a subset of LaTeX mathematical syntax (there's a link of that page of the commands). It can be integrated with Markdown to produce a nice convertor from something a human might type to XHTML+MathML.

The original itexToMML is a C++ library. The current author has developed it in to a ruby extension which is used in the Instiki wiki software (see the nLab for an example). I worked out the correct makefile options to build extensions for PHP, Perl, and Python. I also figured out the correct place to hook it in to PHP Markdown to make that work. I don't know much python so I haven't tried to do the same with python's implementation of markdown but I would really like this to be done, partly because there's a python library for converting MathML to SVG which means that one can serve MathML, SVG, or PNG depending on the browser, thus satisfying everyone (well, probably not everyone). This is what the nForum does.

My version of the itexToMML code is in a BZR repository at http://www.math.ntnu.no/~stacey/code/itexToMML. It's not documented yet - that's on my TODO list. It also needs merging the latest changes from the main itexToMML source - it's a little behind the times.

Oh, and the original itexToMML comes as a ruby gem so it is super easy to install if you use ruby.