Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}")
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")
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}")
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}")
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}"
)
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')
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')
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}")
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")
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}")