diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py
index af3f1cb86..efb0a53bc 100644
--- a/ankiqt/ui/facteditor.py
+++ b/ankiqt/ui/facteditor.py
@@ -281,7 +281,7 @@ class FactEditor(object):
old = tidyHTML(unicode(w.toHtml()))
# only update if something has changed, to preserve the cursor
if new != old:
- w.setHtml(new)
+ w.setHtml('' + new)
if font:
# apply fonts
font = QFont()
@@ -594,7 +594,7 @@ class FactEdit(QTextEdit):
html = re.sub('', "", html)
html = stripHTML(html)
html = html.replace("\n", "
")
- html = re.sub("\s\s+", " ", html).strip()
+ html = html.strip()
return html
def focusOutEvent(self, evt):
diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py
index 981fdf1b8..273d47658 100644
--- a/ankiqt/ui/view.py
+++ b/ankiqt/ui/view.py
@@ -87,7 +87,8 @@ class View(object):
(base, family, size, color))
s += ("body { background-color: " +
self.main.config["backgroundColour"] +
- "; }")
+ ";}\n")
+ s += "div { white-space: pre-wrap; }"
s += ""
return s