mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
replace clozes individually so hints aren't shared
This commit is contained in:
parent
5212f62198
commit
50bfb9dd4b
1 changed files with 9 additions and 12 deletions
|
@ -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, "<span class=cloze>[%s...]</span>" % m.group(3),
|
||||
txt)
|
||||
def repl(m):
|
||||
# replace chosen cloze with type
|
||||
if type == "q":
|
||||
if m.group(3):
|
||||
return "<span class=cloze>[%s...]</span>" % m.group(3)
|
||||
else:
|
||||
return "<span class=cloze>[...]</span>"
|
||||
else:
|
||||
txt = re.sub(reg%ord, "<span class=cloze>[...]</span>", txt)
|
||||
elif type == "a":
|
||||
txt = re.sub(reg%ord, "<span class=cloze>\\1</span>", txt)
|
||||
return "<span class=cloze>%s</span>" % m.group(1)
|
||||
txt = re.sub(reg%ord, repl, txt)
|
||||
# and display other clozes normally
|
||||
return re.sub(reg%".*?", "\\1", txt)
|
||||
|
||||
|
|
Loading…
Reference in a new issue