From 7ecd889d8f6bd9a89fdd782537f2ca3790a01cd6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 12 Jul 2017 10:57:01 +1000 Subject: [PATCH] preserve newlines and indents when pasting text https://anki.tenderapp.com/discussions/ankidesktop/24123-paragraphsnew-lines-not-preserved-when-copypasting-into-anki --- aqt/editor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index 3d94d1579..3a9d0325e 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -310,8 +310,6 @@ var filterHTML = function(html) { var top = $.parseHTML("" + html + "")[0]; filterNode(top); var outHtml = top.innerHTML; - // get rid of nbsp - outHtml = outHtml.replace(/ /ig, " "); //console.log(`input html: ${html}`); //console.log(`outpt html: ${outHtml}`); return outHtml; @@ -1124,7 +1122,10 @@ class EditorWebView(AnkiWebView): return self.editor.urlToLink(txt) # normal text; convert it to HTML - return html.escape(txt) + txt = html.escape(txt) + txt = txt.replace("\n", "
") + txt = txt.replace(" ", " ") + return txt def _processHtml(self, mime): if not mime.hasHtml():