How to use the latex2mathml.converter._convert function in latex2mathml

To help you get started, weโ€™ve selected a few latex2mathml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github roniemartinez / latex2mathml / tests / test_command.py View on Github external
mo.text = "−"
    mi = eTree.SubElement(td, "mi")
    mi.text = "a"
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "b"

    tr = eTree.SubElement(table, "mtr")
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "c"
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "d"

    assert _convert(math) == convert(r"\begin{matrix}-a & b \\ c & d \end{matrix}")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
def test_superscript_and_subscript(math_and_row):
    math, row = math_and_row
    subsup = eTree.SubElement(row, "msubsup")
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "a"
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "c"
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "b"
    assert _convert(math) == convert("a^b_c")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "b"

    tr = eTree.SubElement(table, "mtr")
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "c"
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "d"

    mo = eTree.SubElement(row, "mo")
    mo.text = ")"

    assert _convert(math) == convert(r"\begin{pmatrix}a & b \\ c & d \end{pmatrix}")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
def test_superscript_within_curly_braces(math_and_row):
    math, row = math_and_row
    row = eTree.SubElement(row, "mrow")
    sup = eTree.SubElement(row, "msup")
    mi = eTree.SubElement(sup, "mi")
    mi.text = "a"
    mi = eTree.SubElement(sup, "mi")
    mi.text = "b"
    assert _convert(math) == convert("{a^b}")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
td = eTree.SubElement(tr, "mtd", columnalign="left")
    mn = eTree.SubElement(td, "mn")
    mn.text = "3"

    tr = eTree.SubElement(table, "mtr")
    td = eTree.SubElement(tr, "mtd", columnalign="center")
    mn = eTree.SubElement(td, "mn")
    mn.text = "4"
    td = eTree.SubElement(tr, "mtd", columnalign="right")
    mn = eTree.SubElement(td, "mn")
    mn.text = "5"
    td = eTree.SubElement(tr, "mtd", columnalign="left")
    mn = eTree.SubElement(td, "mn")
    mn.text = "6"

    assert _convert(math) == convert(
        r"\begin{array}{c|rl} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array}"
    )
github roniemartinez / latex2mathml / tests / test_issues.py View on Github external
def test_issue_45_gt(math_and_row):
    math, row = math_and_row
    mn = eTree.SubElement(row, 'mn')
    mn.text = '2'
    mo = eTree.SubElement(row, 'mo')
    mo.text = '>'
    mn = eTree.SubElement(row, 'mn')
    mn.text = '5'
    assert _convert(math) == convert('2 > 5')
github roniemartinez / latex2mathml / tests / test_issues.py View on Github external
def test_issue_45_lt(math_and_row):
    math, row = math_and_row
    mn = eTree.SubElement(row, 'mn')
    mn.text = '2'
    mo = eTree.SubElement(row, 'mo')
    mo.text = '<'
    mn = eTree.SubElement(row, 'mn')
    mn.text = '5'
    assert _convert(math) == convert('2 < 5')
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
def test_root(math_and_row):
    math, row = math_and_row
    root = eTree.SubElement(row, "mroot")
    row = eTree.SubElement(root, "mrow")
    mn = eTree.SubElement(row, "mn")
    mn.text = "2"
    row = eTree.SubElement(root, "mrow")
    mn = eTree.SubElement(row, "mn")
    mn.text = "3"
    assert _convert(math) == convert(r"\sqrt[3]{2}")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
def test_subscript_and_superscript(math_and_row):
    math, row = math_and_row
    subsup = eTree.SubElement(row, "msubsup")
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "a"
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "b"
    mi = eTree.SubElement(subsup, "mi")
    mi.text = "c"
    assert _convert(math) == convert("a_b^c")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "a"
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "b"

    tr = eTree.SubElement(table, "mtr")
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "c"
    td = eTree.SubElement(tr, "mtd")
    mi = eTree.SubElement(td, "mi")
    mi.text = "d"

    assert _convert(math) == convert(r"\matrix{a & b \\ c & d}")