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
sub_right = eTree.SubElement(row, "msub")

    row = eTree.SubElement(over, "mrow")
    sub_left = eTree.SubElement(row, "msub")
    mi = eTree.SubElement(sub_left, "mi")
    mi.text = "z"
    mn = eTree.SubElement(sub_left, "mn")
    mn.text = "1"
    mo = eTree.SubElement(over, "mo", stretchy="true")
    mo.text = "¯"

    mi = eTree.SubElement(sub_right, "mi")
    mi.text = "z"
    mn = eTree.SubElement(sub_right, "mn")
    mn.text = "2"
    assert _convert(math) == convert(r"\bar{z_1} = z_2")
github roniemartinez / latex2mathml / tests / test_command.py View on Github external
def test_binomial(math_and_row):
    math, row = math_and_row
    mo = eTree.SubElement(row, "mo")
    mo.text = "("
    frac = eTree.SubElement(row, "mfrac", linethickness="0")
    _row = eTree.SubElement(frac, "mrow")
    mn = eTree.SubElement(_row, "mn")
    mn.text = "2"
    _row = eTree.SubElement(frac, "mrow")
    mn = eTree.SubElement(_row, "mn")
    mn.text = "3"
    mo = eTree.SubElement(row, "mo")
    mo.text = ")"
    assert _convert(math) == convert(r"\binom{2}{3}")
github roniemartinez / latex2mathml / tests / test_converter.py View on Github external
def test_converter(name: str, latex: str, json: MultiDict):
    parent = {
        "math": {
            "@xmlns": "http://www.w3.org/1998/Math/MathML",
            "@display": "inline",
            "mrow": json,
        }
    }
    bf = BadgerFish(dict_type=MultiDict)
    math = bf.etree(parent)
    assert convert(latex) == _convert(math[0])
github roniemartinez / latex2mathml / tests / test_converter.py View on Github external
def test_attributes():
    assert (
        convert("1")
        == '<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mn>1</mn></mrow></math>'
    )
    assert (
        convert("1", display="block")
        == '<math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mn>1</mn></mrow></math>'
    )
github roniemartinez / latex2mathml / tests / test_issues.py View on Github external
def test_issue_45_amp(math_and_row):
    math, row = math_and_row
    mo = eTree.SubElement(row, 'mo')
    mo.text = '&amp;'
    assert _convert(math) == convert('&')
github roniemartinez / latex2mathml / example.py View on Github external
def convert_to_mathml(latex_input):
    mathml_output = convert(latex_input)
    print(mathml_output)