Metadata-Version: 2.4
Name: retex
Version: 1.7.0a1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Summary: Compile LaTeX documents to PDF, SVG, ODT, HTML and Markdown from Python, with retex, a LuaLaTeX-compatible TeX engine in Rust
Keywords: latex,tex,pdf,typesetting,luatex
Home-Page: https://gitlab.com/severin-lemaignan/retex
License-Expression: CC0-1.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://gitlab.com/severin-lemaignan/retex

# retex for Python

Compile LaTeX documents from Python, to PDF, SVG, ODT, ODP, HTML and
Markdown, with [retex](https://gitlab.com/severin-lemaignan/retex), a
TeX engine written in Rust whose output is pixel-identical to LuaLaTeX's.
retex runs in the Python process: no TeX program is started.

```python
import retex

tex = retex.Retex()
doc = tex(r"""
\documentclass{article}
\begin{document}
Hello, \LaTeX{} from Python! $e^{i\pi} + 1 = 0$
\end{document}
""")

pdf = doc.to_pdf()        # bytes
svg = doc.to_svg()        # str: every page, stacked
odt = doc.to_odt()        # bytes
html = doc.to_html()      # str: one file, fonts and pictures in it
md = doc.to_markdown()    # str
doc.save("hello.pdf")     # or .svg, .odt, .odp, .html, .md
```

A build runs every pass the document needs, BibTeX, biber and makeindex
included. What it reported is in `doc.diagnostics`, `doc.errors` and
`doc.warnings`; a build that writes no output raises `retex.RetexError`,
whose `diagnostics` and `log` say why. In Jupyter, a document shows as
its pages.

Options, all keyword arguments of `Retex`:

| option | meaning |
|---|---|
| `passes` | at most this many passes (default 5; 1 runs TeX once) |
| `shell_escape` | let `\write18` run programs (default `False`) |
| `accessible` | tagged PDF, checked for accessibility (PDF/UA-2) |
| `working_dir` | where the document's own files (pictures, `.bib`) are |
| `job_name` | the job name (default `document`) |
| `files` | `{name: str or bytes}`: files the document reads |
| `keep_files` | keep the build's files (log, `.aux`) in this directory |

`Retex.compile_file(path)` compiles a `.tex` file, its directory being
the working directory.

retex needs a TeX Live installation (2025 or 2026) for the LaTeX
packages and fonts. Builds release the GIL; they run one at a time in a
process, and change the current directory while they run.

Build the wheel with [maturin](https://www.maturin.rs/): `maturin build
--release` in this directory; `cargo xtask python` builds it and runs
`tests/`. For PyPI, a manylinux wheel: `maturin build --release --zig
--compatibility manylinux_2_28` (with [zig](https://ziglang.org/) on
`PATH`).

