fix error in type answer when field has \g etc

This commit is contained in:
Damien Elmes 2012-09-25 14:49:51 +09:00
parent dceb13c720
commit ca2f9acce2

View file

@ -386,9 +386,13 @@ Please run Tools>Maintenance>Empty Cards""")
res += u"<span id=rightanswer><br> {0} <br> {1} </span>".format( res += u"<span id=rightanswer><br> {0} <br> {1} </span>".format(
_(u"Correct answer was:"), cor) _(u"Correct answer was:"), cor)
# and update the type answer area # and update the type answer area
return re.sub(self.typeAnsPat, """ def repl(match):
<span style="font-family: '%s'; font-size: %spx">%s</span>""" % # can't pass a string in directly, and can't use re.escape as it
(self.typeFont, self.typeSize, res), buf) # escapes too much
return """
<span style="font-family: '%s'; font-size: %spx">%s</span>""" % (
self.typeFont, self.typeSize, res)
return re.sub(self.typeAnsPat, repl, buf)
def _contentForCloze(self, txt, idx): def _contentForCloze(self, txt, idx):
matches = re.findall("\{\{c%s::(.+?)\}\}"%idx, txt) matches = re.findall("\{\{c%s::(.+?)\}\}"%idx, txt)