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.

  • I don't know anything like that, but if you are going to write something on your own you may be interested in FlyLatex and Pandoc. I'd personally use something like Textile with Jekyll, unless you can find/create something with LaTeX, I'd like that more. Good luck! – Trylks Aug 12 '13 at 17:30
  • 1
  • Neither javascript nor HTML -- but do you know dvisvgm? It converts dvi to svg which most modern browsers render natively. – Alex Aug 12 '13 at 19:43
  • @ Trylks: I will give pandoc a try. My documents are huge (200+ pages), and the primary output should still be pdf, so switching to another source language is not really an option. – carsten Aug 12 '13 at 21:38
  • @ David Carlile: I stumbled upon it before posting my question. It's nice, but it outputs pdf. I want HTML output. – carsten Aug 12 '13 at 21:39

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.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.