From d47dfc1780d06fe04da8a71ae5161ea558e65930 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 4 Jul 2012 18:17:08 +0900 Subject: [PATCH] don't include audio in {{FrontSide}} --- anki/collection.py | 2 +- anki/media.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/anki/collection.py b/anki/collection.py index 4f366a9ae..d619f7aaa 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -492,7 +492,7 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)): else: format = format.replace("{{cloze:", "{{ca:%d:" % ( data[4]+1)) - fields['FrontSide'] = d['q'] + fields['FrontSide'] = self.media.stripAudio(d['q']) fields = runFilter("mungeFields", fields, model, data, self) html = anki.template.render(format, fields) d[type] = runFilter( diff --git a/anki/media.py b/anki/media.py index 4edf9bcdd..55e0d9261 100644 --- a/anki/media.py +++ b/anki/media.py @@ -121,6 +121,9 @@ If the same name exists, compare checksums.""" txt = re.sub(reg, "", txt) return txt + def stripAudio(self, txt): + return re.sub(self.regexps[0], "", txt) + def escapeImages(self, string): # Feeding webkit unicode can result in it not finding images, so on # linux/osx we percent escape the image paths as utf8. On Windows the