Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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")
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}")
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])
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>'
)
def test_issue_45_amp(math_and_row):
math, row = math_and_row
mo = eTree.SubElement(row, 'mo')
mo.text = '&'
assert _convert(math) == convert('&')
def convert_to_mathml(latex_input):
mathml_output = convert(latex_input)
print(mathml_output)