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):
|
def clozeText(self, txt, ord, type):
|
||||||
reg = clozeReg
|
reg = clozeReg
|
||||||
m = re.search(reg%ord, txt)
|
def repl(m):
|
||||||
if not m:
|
|
||||||
return ""
|
|
||||||
# replace chosen cloze with type
|
# replace chosen cloze with type
|
||||||
if type == "q":
|
if type == "q":
|
||||||
if m.group(3):
|
if m.group(3):
|
||||||
txt = re.sub(
|
return "<span class=cloze>[%s...]</span>" % m.group(3)
|
||||||
reg%ord, "<span class=cloze>[%s...]</span>" % m.group(3),
|
|
||||||
txt)
|
|
||||||
else:
|
else:
|
||||||
txt = re.sub(reg%ord, "<span class=cloze>[...]</span>", txt)
|
return "<span class=cloze>[...]</span>"
|
||||||
elif type == "a":
|
else:
|
||||||
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
|
# and display other clozes normally
|
||||||
return re.sub(reg%".*?", "\\1", txt)
|
return re.sub(reg%".*?", "\\1", txt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue