diff --git a/anki/template/template.py b/anki/template/template.py index 573a88bca..d59f1cfb8 100644 --- a/anki/template/template.py +++ b/anki/template/template.py @@ -196,19 +196,16 @@ class Template(object): def clozeText(self, txt, ord, type): reg = clozeReg - m = re.search(reg%ord, txt) - if not m: - return "" - # replace chosen cloze with type - if type == "q": - if m.group(3): - txt = re.sub( - reg%ord, "[%s...]" % m.group(3), - txt) + def repl(m): + # replace chosen cloze with type + if type == "q": + if m.group(3): + return "[%s...]" % m.group(3) + else: + return "[...]" else: - txt = re.sub(reg%ord, "[...]", txt) - elif type == "a": - txt = re.sub(reg%ord, "\\1", txt) + return "%s" % m.group(1) + txt = re.sub(reg%ord, repl, txt) # and display other clozes normally return re.sub(reg%".*?", "\\1", txt)