Skip to main content

Module api

Module api 

Source
Expand description

Stable, high-level conversion API for using latexml as a library.

Downstream Rust crates depend on latexml and call one function — no binary, no manual Config or binding-dispatch wiring:

let xml = latexml::api::convert_to_xml(r"\documentclass{article}\begin{document}Hi\end{document}")?;
let html = latexml::api::convert_to_html(r"\documentclass{article}\begin{document}Hi\end{document}")?;

§What these encapsulate

The engine is a thread-local singleton, so each call runs on its own worker thread with a large (256 MiB) stack — matching the latexml_oxide binary — so deeply nested math can’t overflow the 8 MiB default stack, and the thread’s #[thread_local] engine roots (~110 MiB) are released via reset_thread_engine before the thread exits (those roots do not run destructors on a bare thread exit). The standard package + contrib binding-dispatch chain is wired for you.

§Requirements at runtime

Same host dependencies as the binary: a TeX distribution on PATH for packages/classes/fonts, and (only for figure-bearing HTML) the graphics tools. XML/XSLT/RelaxNG assets are embedded.

For finer control (preloads, search paths, encoding, whatsin/out, split, …), drive crate::converter::Converter and crate::post directly; this module is the batteries-included entrypoint.

Functions§

convert_to_html
Convert a TeX/LaTeX source string all the way to a standalone HTML5 document (LaTeXML XML + the HTML post-processing pipeline, with Presentation MathML).
convert_to_xml
Convert a TeX/LaTeX source string to LaTeXML XML (the intermediate representation, before any HTML post-processing).