{"id":21819924,"url":"https://github.com/dmoj/texoid","last_synced_at":"2025-04-14T02:41:21.918Z","repository":{"id":56260621,"uuid":"65751521","full_name":"DMOJ/texoid","owner":"DMOJ","description":"Lightweight Python server for securely rendering LaTeX diagrams to SVG and PNG within Docker.","archived":false,"fork":false,"pushed_at":"2023-03-09T12:00:23.000Z","size":40,"stargazers_count":11,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T18:17:59.319Z","etag":null,"topics":["latex","png","python","renderer","server","svg"],"latest_commit_sha":null,"homepage":"https://dmoj.ca/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DMOJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-15T17:33:47.000Z","updated_at":"2024-09-01T19:49:07.000Z","dependencies_parsed_at":"2024-12-01T06:52:37.182Z","dependency_job_id":null,"html_url":"https://github.com/DMOJ/texoid","commit_stats":{"total_commits":36,"total_committers":4,"mean_commits":9.0,"dds":0.5,"last_synced_commit":"f482221061e0d5e33296e60c77a0ead2c985f649"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMOJ%2Ftexoid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMOJ%2Ftexoid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMOJ%2Ftexoid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMOJ%2Ftexoid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DMOJ","download_url":"https://codeload.github.com/DMOJ/texoid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248812179,"owners_count":21165380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latex","png","python","renderer","server","svg"],"created_at":"2024-11-27T16:27:11.041Z","updated_at":"2025-04-14T02:41:21.886Z","avatar_url":"https://github.com/DMOJ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Texoid [![Build Status](https://img.shields.io/travis/DMOJ/texoid.svg)](https://travis-ci.org/DMOJ/texoid)  [![PyPI](https://img.shields.io/pypi/v/texoid.svg)](https://pypi.org/project/texoid/) [![PyPI - Format](https://img.shields.io/pypi/format/texoid.svg)](https://pypi.org/project/texoid/) [![PyPI - License](https://img.shields.io/pypi/l/texoid.svg)](https://pypi.org/project/texoid/)\n\nPython server for LaTeX math rendering to SVG and PNG.\nIt is lightweight and perfect for embedding LaTeX documents into webpages, without the hassle of rendering the documents yourself.\n\n## Installation\nTexoid is super simple to set up and use.\n\n```shell\n$ pip install texoid\n```\n\nTexoid uses [`texbox`](https://github.com/DMOJ/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](https://docs.docker.com/install/).\n\nAlternatively, 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:\n\n```shell\n$ apt-get install texlive-latex-base texlive-binaries imagemagick\n```\n\n## Running Texoid\n\n### With Docker\nTo run Texoid with Docker, simply run the following command with a user in the `docker` group:\n\n```shell\n$ texoid --port=\u003cport\u003e --docker\n```\n\nThis will automatically pull the latest `texbox` image and start using it.\n\n### Without Docker\nTo start the Texoid without Docker, use:\n\n```shell\n$ export LATEX_BIN=\u003cpath to latex\u003e\n$ export DVISVGM_BIN=\u003cpath to dvisvgm\u003e\n$ export CONVERT_BIN=\u003cpath to convert\u003e\n$ texoid --port=\u003cport\u003e\n```\n\nThe environment variables are not necessary if the respective executables are present in `$PATH`. Here, `convert` refers to ImageMagick's `convert` tool.\n\n## Using Texoid\n\nTexoid 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`.\n\nTexoid 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.\n\n### Response\nThe response will always contain a boolean field, `success`.\n\nIf `success` is `true`:\n\n* `svg` will contain the SVG source of the rendered document\n* `png` will contain a base64-encoded binary PNG file\n* `meta` will be a dict containing two entries:\n  * `width`, the width of the rendered document in pixels\n  * `height`, the height of the rendered document, again in pixels\n  * these arguments are what the SVG/PNGs generated should be sized by to display properly in webpages\n\nIf `success` is `false`, the response will contain an `error` field with the LaTeX error output.\n\n### Examples\nIn these examples, a Texoid server is assumed to be running on `localhost`, port 8888. We will be rendering a simple LaTeX document:\n\n```latex\n\\documentclass{standalone}\n\\begin{document}\n$E=mc^2$\n\\end{document}\n```\n\n#### A successful render\n```shell\n$ curl -H 'Content-Type: text/plain' --data-raw '\\documentclass{standalone}\\begin{document}$E=mc^2$\\end{document}' localhost:8888\n{\n    \"success\": true,\n    \"svg\": \"\u003c?xml version='1.0'?\u003e\u003csvg...\u003c/svg\u003e\",\n    \"png\": \"iVBORw0KGgoA...RK5CYII=\",\n    \"meta\": {\n        \"width\": \"48\", \n        \"height\": \"10\"\n    }\n}\n```\n\n#### A malformed request\n```shell\n$ curl -H 'Content-Type: text/plain' --data 'malformed' localhost:8888\n{\n    \"success\": false,\n    \"error\": \"This is pdfTeX, Version 3.14159265-2.6-1.40.15...LaTeX Error: Missing \\\\begin{document}...\"\n}\n```\n\nAnd that's it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmoj%2Ftexoid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmoj%2Ftexoid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmoj%2Ftexoid/lists"}