[Tex/LaTex] Javascript LaTeX to HTML interpreter?


Is there a possibility to 'render' latex code with your browser?

I have some *.tex files which I would like to render a HTML version of (with HTML-navigation, hyperlinks, etc). However – running some tex2html converter everytime is quite annoying, especially since I use a lot of special packages that are not supported by most converters I tried so far, so I would need to post-process the files everytime I change something in my source document, which happens very often.

What I would really like to have is a javascript library that parses a TeX file and renders an HTML webpage from it using DOM. It doesn't need to be complete in the sense that all CTAN packages are supported, but it should be extendable in the sense that I can plug in my own javascript code to render some self-defined environments and commands.

So what I'm looking for is a javascript to HTML interpreter. Is there such a thing, or would I need to write something up myself?

PS: I know about MathJax, which does an excellent job at rendering math, but I would like to render whole documents, including preamble and custom command definitions.

Best Answer

Yes, I think I wrote almost exactly what you are asking for: LaTeX.js. I got most of the standard LaTeX macros working exactly as they should; the parsing of the text is pretty much perfect. So the hard work is done, now it's just about adding more macros.

For instance, I have not implemented tables yet, and I haven't implemented cross-references yet. Those will be next, I think, but it might take a few more weeks or so.

However, your PS is not going to be possible with LaTeX.js. TeX (and thus LaTeX) cannot be successfully parsed as a context-free grammar, which is exactly what I am doing. So loading packages and parsing the preamble will not be possible.