Documentation version 0.1.0a4

MathML to LaTeX and text. One style, always renders.

mathconv converts math formulas from MathML, the markup of web pages, e-books and journal articles, into LaTeX that KaTeX and MathJax render, or into readable plain text. It is a Python package with a Rust core, made for converting millions of formulas.

pip install --pre mathconv
npm install @mathconv/mathconv

Open the playground Read the documentation

Try it

Output · LaTeX
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
● fully convertedOpen in the playground

Key figures

Conversions

Usage

import mathconv

mathml = "<math><msqrt><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></msqrt></math>"
mathconv.convert(mathml)
# '\\sqrt{x^2 + 1}'
mathconv.convert(mathml, target="text")
# 'sqrt(x^2 + 1)'
import { convert } from "@mathconv/mathconv";

const mathml = '<math><msqrt><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></msqrt></math>';
convert(mathml);
// '\\sqrt{x^2 + 1}'
convert(mathml, { target: "text" });
// 'sqrt(x^2 + 1)'

Each call takes one formula, in presentation or content MathML. A Converter keeps options and converts lists; the documentation covers the API, the options and the output style.