Texoid

Python server for LaTeX math rendering to SVG and PNG. It is lightweight and perfect for embedding LaTeX documents into webpages, without the hassle of rendering the documents yourself.
Installation
Texoid is super simple to set up and use.
$ pip install texoid
Texoid uses texbox, a Docker image built for converting LaTeX documents to SVG and PNG securely, without exposing your system to malicious LaTeX code. To use Texoid with texbox, install Docker.
Alternatively, Texoid can directly use LaTeX to render documents to DVI format, dvisvgm to convert to SVGs, and ImageMagick to convert SVGs into PNGs. On a typical Debian or Ubuntu machine, you can the dependencies for this with:
$ apt-get install texlive-latex-base texlive-binaries imagemagick
Running Texoid
With Docker
To run Texoid with Docker, simply run the following command with a user in the docker group:
$ texoid --port=<port> --docker
This will automatically pull the latest texbox image and start using it.
Without Docker
To start the Texoid without Docker, use:
$ LATEX_BIN=<path to latex> DVISVGM_BIN=<path to dvisvgm> CONVERT_BIN=<path to convert> texoid --port=<port>
The environment variables are not necessary if all three executables are present in /usr/bin. Here, convert refers to ImageMagick's convert tool.
Using Texoid
Texoid expects POST body to contain the LaTeX document to render. You should send the request with an appropriate Content-Type, for example, text/plain, application/x-tex, or text/x-tex. Do not use application/x-www-form-urlencoded.
Texoid also has a legacy API. This API uses application/x-www-form-urlencoded as Content-Type, and sends the LaTeX code form-encoded in the q field.
Response
The response will always contain a boolean field, success.
If success is true:
svgwill contain the SVG source of the rendered documentpngwill contain a base64-encoded binary PNG filemetawill be a dict containing two entries:width, the width of the rendered document in pixelsheight, the height of the rendered document, again in pixels- these arguments are what the SVG/PNGs generated should be sized by to display properly in webpages
If success is false, the response will contain an error field with the LaTeX error output.
Examples
In these examples, a Texoid server is assumed to be running on localhost, port 8888. We will be rendering a simple LaTeX document:
\documentclass{standalone}
\begin{document}
$E=mc^2$
\end{document}
A successful render
$ curl -H 'Content-Type: text/plain' --data-raw '\documentclass{standalone}\begin{document}$E=mc^2$\end{document}' localhost:8888
{"success": true, "svg": "<?xml version='1.0'?><svg....</svg>", "png": "iVBORw0KGgoA....RK5CYII=", "meta": {"width": "48", "height": "10"}}
A malformed request
$ curl -H 'Content-Type: text/plain' --data 'malformed' localhost:8888
{"success": false, "error": "This is pdfTeX, Version 3.14159265-2.6-1.40.15...LaTeX Error: Missing \\begin{document}..."}
And that's it!
Metadata
Release files for texoid 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| texoid-0.2.1.tar.gz | 19.9 kB | Without provenance | Details for texoid-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| texoid-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for texoid-0.2.1-py3-none-any.whl |
Total release size: 39.3 kB
Release files / texoid-0.2.1.tar.gz
| Download URL | texoid-0.2.1.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
704a8e6954b4e07f17248c38bfb23567d0fb9196c63d5a96ef223fbb86f86c61
|
|
BLAKE2b-256 checksum How to use checksums |
4e2ec2bc440aa4ce19985ca20321c400d89a82fee796e125dc3e4a49ff930965
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Release files / texoid-0.2.1-py3-none-any.whl
| Download URL | texoid-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cbd654f05c6fe4c880405e14ca8cbc605312855bc3a660d325efc05f0813db5
|
|
BLAKE2b-256 checksum How to use checksums |
c6f97db1aee7b7b865bdf39b42df00aae3fdb928a65036c5a6ba17f96de874a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Security for texoid 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.