diff --git a/aqt/editor.py b/aqt/editor.py index e284e4a2c..52b8ef297 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -939,8 +939,13 @@ class EditorWebView(AnkiWebView): # normal text; convert it to HTML txt = html.escape(txt) txt = txt.replace("\n", "
")\ - .replace("\t", " "*4)\ - .replace(" ", " ") + .replace("\t", " "*4) + + # if there's more than one consecutive space, + # use non-breaking spaces for the second one on + def repl(match): + return " " + match.group(1).replace(" ", " ") + txt = re.sub(" ( +)", repl, txt) return txt