From 7a1c4035da8f100a13ab2a49b8278c6030d434d4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 24 Apr 2012 01:51:10 +0900 Subject: [PATCH] don't throw error when typing empty cloze --- aqt/reviewer.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 24f21757b..0b4b67901 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -316,8 +316,12 @@ img { max-width: 95%; max-height: 95%; } break if not self.typeCorrect: if self.typeCorrect is None: - return re.sub( - self.typeAnsPat, _("Type answer: unknown field %s") % fld, buf) + if clozeIdx: + warn = _("""\ +Please run Tools>Maintenance>Empty Cards""") + else: + warn = _("Type answer: unknown field %s") % fld + return re.sub(self.typeAnsPat, warn, buf) else: # empty field, remove type answer pattern return re.sub(self.typeAnsPat, "", buf) @@ -346,7 +350,9 @@ img { max-width: 95%; max-height: 95%; } def _contentForCloze(self, txt, idx): matches = re.findall("\{\{c%s::(.+?)\}\}"%idx, txt) - if len(matches) > 1: + if not matches: + return None + elif len(matches) > 1: txt = ", ".join(matches) else: txt = matches[0]