From 50bfb9dd4bfe4732569be359c0f6da7845acc7d6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 5 Jul 2012 03:17:16 +0900 Subject: [PATCH] replace clozes individually so hints aren't shared --- anki/template/template.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) 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)