From 4f3bd476d5767d98ab31695b33d54b58e008d9af Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 16 Dec 2019 14:39:54 +1000 Subject: [PATCH] fix incorrect marks not showing properly when typing answer https://anki.tenderapp.com/discussions/ankidesktop/37513-thai-superscripts-not-checked --- aqt/reviewer.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index f01fcbd9f..03b228310 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -440,12 +440,14 @@ Please run Tools>Empty Cards""") else: res = "" for ok, txt in givenElems: + txt = self._noLoneMarks(txt) if ok: res += good(txt) else: res += bad(txt) res += "

" for ok, txt in correctElems: + txt = self._noLoneMarks(txt) if ok: res += good(txt) else: @@ -453,6 +455,13 @@ Please run Tools>Empty Cards""") res = "
" + res + "
" return res + def _noLoneMarks(self, s): + # ensure a combining character at the start does not join to + # previous text + if s and ucd.category(s[0]).startswith("M"): + return "\xa0" + s + return s + def _getTypedAnswer(self): self.web.evalWithCallback("typeans ? typeans.value : null", self._onTypedAnswer)