mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Use @classmethod on methods that do not depends on instance state
This commit is contained in:
parent
ed8340a4e3
commit
ebd07a064e
1 changed files with 5 additions and 3 deletions
|
@ -200,12 +200,13 @@ class Template:
|
||||||
return "{unknown field %s}" % tag_name
|
return "{unknown field %s}" % tag_name
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def clozeText(self, txt, ord, type) -> str:
|
@classmethod
|
||||||
|
def clozeText(cls, txt, ord, type) -> str:
|
||||||
reg = clozeReg
|
reg = clozeReg
|
||||||
if not re.search(reg % ord, txt):
|
if not re.search(reg % ord, txt):
|
||||||
# No Cloze deletion was found in txt.
|
# No Cloze deletion was found in txt.
|
||||||
return ""
|
return ""
|
||||||
txt = self._removeFormattingFromMathjax(txt, ord)
|
txt = cls._removeFormattingFromMathjax(txt, ord)
|
||||||
|
|
||||||
def repl(m):
|
def repl(m):
|
||||||
# replace chosen cloze with type
|
# replace chosen cloze with type
|
||||||
|
@ -225,7 +226,8 @@ class Template:
|
||||||
# and display other clozes normally
|
# and display other clozes normally
|
||||||
return re.sub(reg % r"\d+", "\\2", txt)
|
return re.sub(reg % r"\d+", "\\2", txt)
|
||||||
|
|
||||||
def _removeFormattingFromMathjax(self, txt, ord) -> str:
|
@classmethod
|
||||||
|
def _removeFormattingFromMathjax(cls, txt, ord) -> str:
|
||||||
"""Marks all clozes within MathJax to prevent formatting them.
|
"""Marks all clozes within MathJax to prevent formatting them.
|
||||||
|
|
||||||
Active Cloze deletions within MathJax should not be wrapped inside
|
Active Cloze deletions within MathJax should not be wrapped inside
|
||||||
|
|
Loading…
Reference in a new issue