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
|
break
|
||||||
if not self.typeCorrect:
|
if not self.typeCorrect:
|
||||||
if self.typeCorrect is None:
|
if self.typeCorrect is None:
|
||||||
return re.sub(
|
if clozeIdx:
|
||||||
self.typeAnsPat, _("Type answer: unknown field %s") % fld, buf)
|
warn = _("""\
|
||||||
|
Please run Tools>Maintenance>Empty Cards""")
|
||||||
|
else:
|
||||||
|
warn = _("Type answer: unknown field %s") % fld
|
||||||
|
return re.sub(self.typeAnsPat, warn, buf)
|
||||||
else:
|
else:
|
||||||
# empty field, remove type answer pattern
|
# empty field, remove type answer pattern
|
||||||
return re.sub(self.typeAnsPat, "", buf)
|
return re.sub(self.typeAnsPat, "", buf)
|
||||||
|
@ -346,7 +350,9 @@ img { max-width: 95%; max-height: 95%; }
|
||||||
|
|
||||||
def _contentForCloze(self, txt, idx):
|
def _contentForCloze(self, txt, idx):
|
||||||
matches = re.findall("\{\{c%s::(.+?)\}\}"%idx, txt)
|
matches = re.findall("\{\{c%s::(.+?)\}\}"%idx, txt)
|
||||||
if len(matches) > 1:
|
if not matches:
|
||||||
|
return None
|
||||||
|
elif len(matches) > 1:
|
||||||
txt = ", ".join(matches)
|
txt = ", ".join(matches)
|
||||||
else:
|
else:
|
||||||
txt = matches[0]
|
txt = matches[0]
|
||||||
|
|
Loading…
Reference in a new issue