From ebd07a064e0ffdc469d52a9b4da7906b10ae2507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Pokorn=C3=BD=20=28Rai=29?= Date: Wed, 25 Dec 2019 15:11:22 +0100 Subject: [PATCH] Use @classmethod on methods that do not depends on instance state --- anki/template/template.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/anki/template/template.py b/anki/template/template.py index f1fc1f882..8194e5720 100644 --- a/anki/template/template.py +++ b/anki/template/template.py @@ -200,12 +200,13 @@ class Template: return "{unknown field %s}" % tag_name return txt - def clozeText(self, txt, ord, type) -> str: + @classmethod + def clozeText(cls, txt, ord, type) -> str: reg = clozeReg if not re.search(reg % ord, txt): # No Cloze deletion was found in txt. return "" - txt = self._removeFormattingFromMathjax(txt, ord) + txt = cls._removeFormattingFromMathjax(txt, ord) def repl(m): # replace chosen cloze with type @@ -225,7 +226,8 @@ class Template: # and display other clozes normally 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. Active Cloze deletions within MathJax should not be wrapped inside