fix issues with clozes and <% %>

This commit is contained in:
Damien Elmes 2013-01-04 14:39:06 +09:00
parent df43ef26d0
commit 0447cb4f41
3 changed files with 8 additions and 2 deletions

View File

@ -498,9 +498,13 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)):
if type == "q":
format = format.replace("{{cloze:", "{{cq:%d:" % (
data[4]+1))
format = format.replace("<%cloze:", "<%%cq:%d:" % (
data[4]+1))
else:
format = format.replace("{{cloze:", "{{ca:%d:" % (
data[4]+1))
format = format.replace("<%cloze:", "<%%ca:%d:" % (
data[4]+1))
fields['FrontSide'] = stripSounds(d['q'])
fields = runFilter("mungeFields", fields, model, data, self)
html = anki.template.render(format, fields)

View File

@ -549,7 +549,9 @@ select id from notes where mid = ?)""" % " ".join(map),
sflds = splitFields(flds)
map = self.fieldMap(m)
ords = set()
for fname in re.findall("{{cloze:(.+?)}}", m['tmpls'][0]['qfmt']):
matches = re.findall("{{cloze:(.+?)}}", m['tmpls'][0]['qfmt'])
matches += re.findall("<%cloze:(.+?)%>", m['tmpls'][0]['qfmt'])
for fname in matches:
if fname not in map:
continue
ord = map[fname][0]

View File

@ -28,7 +28,7 @@ Matthew Duggan, Matthew Holtz, Meelis Vasser, Michael Keppler, Michael
Montague, Michael Penkov, Michal Čadil, Nathanael Law, Nick Cook, Niklas
Laxström, Nguyễn Hào Khôi, Norbert Nagold, Ole Guldberg,
Pcsl88, Petr Michalec, Piotr Kubowicz, Richard Colley, Roland Sieker,
Samson Melamed, Stefaan De Pooter, Susanna Björverud, Sylvain Durand,
Samson Melamed, Stefaan De Pooter, Silja Ijas, Susanna Björverud, Sylvain Durand,
Tacutu, Timm Preetz, Timo Paulssen, Ursus, Victor Suba, %s
Xtru."""% _("<!--about diag--> and")}
abouttext += '<p>' + _("""\