anki/pylib/tests/test_template.py
Damien Elmes 1f2e00690f move the rest of Anki's code out of pystache
In the process of factoring out the field filtering, the "extra"
and "fullname" args are just passed in as a blank string now.
Extra was functionality that allowed a field modifier to be defined
as "filtername(arg1,arg2):field", and fullname was the name of the
field including any provided field modifiers. From grepping through
the add-ons on AnkiWeb, neither appears to have been used.
2020-01-08 17:15:46 +10:00

17 lines
608 B
Python

from anki.template2 import _removeFormattingFromMathjax
def test_remove_formatting_from_mathjax():
assert _removeFormattingFromMathjax(r"\(2^{{c3::2}}\)", 3) == r"\(2^{{C3::2}}\)"
txt = (
r"{{c1::ok}} \(2^2\) {{c2::not ok}} \(2^{{c3::2}}\) \(x^3\) "
r"{{c4::blah}} {{c5::text with \(x^2\) jax}}"
)
# Cloze 2 is not in MathJax, so it should not get protected against
# formatting.
assert _removeFormattingFromMathjax(txt, 2) == txt
txt = r"\(a\) {{c1::b}} \[ {{c1::c}} \]"
assert _removeFormattingFromMathjax(txt, 1) == (r"\(a\) {{c1::b}} \[ {{C1::c}} \]")