fix incorrect marks not showing properly when typing answer

https://anki.tenderapp.com/discussions/ankidesktop/37513-thai-superscripts-not-checked
This commit is contained in:
Damien Elmes 2019-12-16 14:39:54 +10:00
parent a2c9b160ca
commit 4f3bd476d5

View file

@ -440,12 +440,14 @@ Please run Tools>Empty Cards""")
else: else:
res = "" res = ""
for ok, txt in givenElems: for ok, txt in givenElems:
txt = self._noLoneMarks(txt)
if ok: if ok:
res += good(txt) res += good(txt)
else: else:
res += bad(txt) res += bad(txt)
res += "<br>&darr;<br>" res += "<br>&darr;<br>"
for ok, txt in correctElems: for ok, txt in correctElems:
txt = self._noLoneMarks(txt)
if ok: if ok:
res += good(txt) res += good(txt)
else: else:
@ -453,6 +455,13 @@ Please run Tools>Empty Cards""")
res = "<div><code id=typeans>" + res + "</code></div>" res = "<div><code id=typeans>" + res + "</code></div>"
return 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): def _getTypedAnswer(self):
self.web.evalWithCallback("typeans ? typeans.value : null", self._onTypedAnswer) self.web.evalWithCallback("typeans ? typeans.value : null", self._onTypedAnswer)