mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
avoid nbsp for single spaces when pasting text
https://anki.tenderapp.com/discussions/ankidesktop/32823-all-spaces-are-being-replaced-with-nbsp-when-pasting-219-linux
This commit is contained in:
parent
fed15f5b90
commit
444abfff94
1 changed files with 7 additions and 2 deletions
|
@ -939,8 +939,13 @@ class EditorWebView(AnkiWebView):
|
|||
# normal text; convert it to HTML
|
||||
txt = html.escape(txt)
|
||||
txt = txt.replace("\n", "<br>")\
|
||||
.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
|
||||
|
||||
|
|
Loading…
Reference in a new issue