Tex markup, how to display it in html using python?

Tex pegging support has recently been added to the following Exchange sites:

These sites use the client side of Mathjax to correctly format the submitted formulas to the user.

Since this new feature was added, the StackExchange API returns a JSON question / answer text with formulas separated by the $ char Tex Markup tag ( here's an example).
StackPrinter , built on this API, simply prints the returned text, full $ with excellent results .

I am looking for a server-side Python library that can parse and convert JSON data to correctly display Tex Markup in Html.
Do you know any solution?

Application Details:
Platform: Google App Engine
Frame: webpy

+4
source share
1 answer

You can try combining the TeX-to-DVI tool (e.g. tex.latex2dvi or pytex ) with the DVI-to-image tool (e.g. dvipng ). To implement this on the server side, you will need an API endpoint that accepts TeX code as input and serves to output the image. Thus, you can display mathematical formulas in the form of images, pointing to their source on this URL with the appropriate parameters. It's quite complicated, but the good news is that the Google Chart Math Formulas API already provides such a service.

In any case, I would consider using MathML to display mathematical notation on the client side, since all major web browsers (except Internet Explorer) support this function in accordance with HTML5 standards. Or just enable Mathjax, for example StackExchange (this is also client-side rendering). This seems like the easiest and cross-platform alternative.

+2
source

Source: https://habr.com/ru/post/1334187/


All Articles