diff --git a/aqt/editor.py b/aqt/editor.py
index 251322847..e284e4a2c 100644
--- a/aqt/editor.py
+++ b/aqt/editor.py
@@ -938,7 +938,10 @@ class EditorWebView(AnkiWebView):
# normal text; convert it to HTML
txt = html.escape(txt)
- txt = txt.replace("\n", "
")
+ txt = txt.replace("\n", "
")\
+ .replace("\t", " "*4)\
+ .replace(" ", " ")
+
return txt
def _processHtml(self, mime):