From d90652d0d6d3faffcaa32269d517164dcb17df4e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 20 May 2013 17:56:01 +0900 Subject: [PATCH] a hack to ensure hr falls before answer comparsion --- aqt/reviewer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index f09e8856e..fae03c872 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -385,6 +385,9 @@ Please run Tools>Empty Cards""") self.web.eval("_getTypedText();") if not self.typeCorrect or not self.typedAnswer: return re.sub(self.typeAnsPat, "", buf) + origSize = len(buf) + buf = buf.replace("
", "") + hadHR = len(buf) != origSize # munge correct value parser = HTMLParser.HTMLParser() cor = stripHTML(self.mw.col.media.strip(self.typeCorrect)) @@ -396,9 +399,14 @@ Please run Tools>Empty Cards""") def repl(match): # can't pass a string in directly, and can't use re.escape as it # escapes too much - return """ + s = """ %s""" % ( self.typeFont, self.typeSize, res) + if hadHR: + # a hack to ensure the q/a separator falls before the answer + # comparison when user is using {{FrontSide}} + s = "
" + s + return s return re.sub(self.typeAnsPat, repl, buf) def _contentForCloze(self, txt, idx):