# Are there any server-side LaTeX to HTML-CSS converters?

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.

-
Welcome to TeX.SE. –  ℝaphink May 25 '11 at 20:37
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 Lindig Jun 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. –  syockit Jan 5 '14 at 6:19

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.

-

You're probably looking for tex4ht. See my answer to this post.

-

tex4ht does a reasonable job translating latex to html; it does allow you to supply a *.cfg file with css instructions, e.g.

   \Css{%
div.document{font: Verdana,Tahoma,Arial,sans-serif;}
div.document { margin-left: 80px; margin-right: 80px;
div.quote{background: linen;}
p.quote{background: red;}
}


but it does convert equations to images

-
Yeah, I was hoping to get the equations in straight HTML+CSS, and not images. I can fairly easily generate high quality formula equations by just using latex + dvipng –  slacy May 26 '11 at 19:49

I would believe it is possible to use Mathjax on the server side, here is how.

1. Write a program that uses Chrome's core to render a HTML page with Mathjax.
2. Read the output of completely rendered page

You are done.

Of course, the main reason to use MathJax is to be cross browser capable. This allows you to work for only one browser.

-
Wouldn't browser sniffing help avoid compatibility problems anyway? –  syockit Jan 5 '14 at 6:15
Now a reality: github.com/gwicke/mathoid (uses PhantomJS, essentially a headless Chrome). Produces SVG. Could be modified for HTML-CSS but that wouldn't work across browsers... –  Beni Cherniavsky-Paskin Apr 3 '14 at 23:57