4

The Tex markup support has been recently added to the following Stack Exchange sites:

These sites are using the client side Mathjax library to correctly format the submitted formulas to the user.

Since this new feature was added, the StackExchange API returns the JSON question/answers text with formulas delimited by the $ char Tex Markup (here an example).
StackPrinter, built on this API, merely prints the returned text full of $ with an orrible result.

I'm searching for a server side Python library that can parse and trasform the JSON Data to properly render the Tex Markup in Html.
Do you know any solution?

Application details:
Platform: Google App Engine
Framework: webpy

2
  • Why not including Mathjax in your html pages as stackexchange does? Commented Jan 4, 2011 at 10:33
  • yes, it's an option but I would like to know if exist a possible solution server side (probably not for the fonts problem). Commented Jan 4, 2011 at 10:54

1 Answer 1

2

You could try combining a TeX-to-DVI tool (such as tex.latex2dvi or pytex) with a DVI-to-image tool (such as dvipng). To implement this on the server side, you would need an API endpoint that takes TeX code as input and serves an image as output. This way, you can render math formulas as images by pointing their source to that URL, with the corresponding parameters. This is quite complex, but the good news is that Google Chart API for math formulas already provides such service.

Anyway, I would consider using MathML to render math notation on the client side, since all major web browsers (except Internet Explorer) support this feature in compliance with HTML5 standards. Or just including Mathjax like StackExchange (this is client-side markup rendering too). This seems the most simple and cross-platform alternative.

Sign up to request clarification or add additional context in comments.

1 Comment

MathML has its own pitfalls — trying to find the right combination of doctype and MIME type and other browser sniffing triggers for your page to even load, let alone render consistently across browsers, can be difficult — if it's even possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.