Skip to content

asnunes/py-mathml-to-latex

Repository files navigation

mathml-to-latex

It converts MathML to LaTeX. Based on the Node.js version of the mathml-to-latex library.

Installation

pip install mathml-to-latex

Usage

from mathml_to_latex.converter import MathMLToLaTeX

mathml = """
<math>
    <mrow>
        <mi>A</mi>
        <mo>=</mo>
        <mfenced open = "[" close="]">
        <mtable>
            <mtr>
            <mtd><mi>x</mi></mtd>
            <mtd><mi>y</mi></mtd>
            </mtr>
            <mtr>
            <mtd><mi>z</mi></mtd>
            <mtd><mi>w</mi></mtd>
            </mtr>
        </mtable>
        </mfenced>
    </mrow>
</math>
"""

result = MathMLToLaTeX().convert(mathml)
# A = \begin{bmatrix} x & y \\ z & w \end{bmatrix}

Running Tests

python -m unittest discover tests

Using Docker

docker build -t mathml-to-latex-test .
docker run mathml-to-latex-test

About

Python tool to convert mathml string to LaTeX equation string.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages