mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
don't throw error when typing empty cloze
This commit is contained in:
parent
f898a787c9
commit
7a1c4035da
1 changed files with 9 additions and 3 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue