2020-01-08 08:15:46 +01:00
|
|
|
from anki.template2 import _removeFormattingFromMathjax
|
2019-12-22 04:28:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_remove_formatting_from_mathjax():
|
2020-01-08 08:15:46 +01:00
|
|
|
assert _removeFormattingFromMathjax(r"\(2^{{c3::2}}\)", 3) == r"\(2^{{C3::2}}\)"
|
2019-12-22 04:28:29 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
txt = (
|
|
|
|
r"{{c1::ok}} \(2^2\) {{c2::not ok}} \(2^{{c3::2}}\) \(x^3\) "
|
|
|
|
r"{{c4::blah}} {{c5::text with \(x^2\) jax}}"
|
|
|
|
)
|
2019-12-22 04:28:29 +01:00
|
|
|
# Cloze 2 is not in MathJax, so it should not get protected against
|
|
|
|
# formatting.
|
2020-01-08 08:15:46 +01:00
|
|
|
assert _removeFormattingFromMathjax(txt, 2) == txt
|
2019-12-22 04:28:29 +01:00
|
|
|
|
2019-12-25 05:18:34 +01:00
|
|
|
txt = r"\(a\) {{c1::b}} \[ {{c1::c}} \]"
|
2020-01-08 08:15:46 +01:00
|
|
|
assert _removeFormattingFromMathjax(txt, 1) == (r"\(a\) {{c1::b}} \[ {{C1::c}} \]")
|