mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
allow empty clozes
instead of considering a cloze note with no clozes marked as invalid, treat it as the first card and show a warning during review
This commit is contained in:
parent
b7d9935b99
commit
3382af2877
3 changed files with 11 additions and 2 deletions
|
@ -46,6 +46,8 @@ SYNC_ZIP_SIZE = int(2.5*1024*1024)
|
|||
SYNC_URL = os.environ.get("SYNC_URL") or "https://beta.ankiweb.net/sync/"
|
||||
SYNC_VER = 5
|
||||
|
||||
HELP_SITE="http://ankisrs.net/docs/dev/manual.html"
|
||||
|
||||
# Labels
|
||||
##########################################################################
|
||||
|
||||
|
|
|
@ -544,6 +544,9 @@ select id from notes where mid = ?)""" % " ".join(map),
|
|||
"{{c(\d+)::[^}]*?}}", sflds[ord])])
|
||||
if -1 in ords:
|
||||
ords.remove(-1)
|
||||
if not ords:
|
||||
# empty clozes use first ord
|
||||
return [0]
|
||||
return list(ords)
|
||||
|
||||
# Sync handling
|
||||
|
|
|
@ -4,6 +4,7 @@ import collections
|
|||
from anki.utils import stripHTML
|
||||
from anki.hooks import runFilter
|
||||
from anki.template import furigana; furigana.install()
|
||||
from anki.consts import HELP_SITE
|
||||
|
||||
clozeReg = r"\{\{c%s::(.*?)(::(.*?))?\}\}"
|
||||
|
||||
|
@ -196,8 +197,11 @@ class Template(object):
|
|||
reg = clozeReg
|
||||
m = re.search(reg%ord, txt)
|
||||
if not m:
|
||||
# cloze doesn't exist; return empty
|
||||
return ""
|
||||
# cloze doesn't exist; return whole text
|
||||
return (txt + "<p><font size=2>" + _(
|
||||
"No cloze deletions found; showing whole field. (%s)") % (
|
||||
"<a href=%s#cloze>%s</a>" % (HELP_SITE, _("help"))) +
|
||||
"</font>")
|
||||
# replace chosen cloze with type
|
||||
if type == "q":
|
||||
if m.group(3):
|
||||
|
|
Loading…
Reference in a new issue