mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
preserve newlines and indents when pasting text
https://anki.tenderapp.com/discussions/ankidesktop/24123-paragraphsnew-lines-not-preserved-when-copypasting-into-anki
This commit is contained in:
parent
14597bd888
commit
7ecd889d8f
1 changed files with 4 additions and 3 deletions
|
@ -310,8 +310,6 @@ var filterHTML = function(html) {
|
||||||
var top = $.parseHTML("<ankitop>" + html + "</ankitop>")[0];
|
var top = $.parseHTML("<ankitop>" + html + "</ankitop>")[0];
|
||||||
filterNode(top);
|
filterNode(top);
|
||||||
var outHtml = top.innerHTML;
|
var outHtml = top.innerHTML;
|
||||||
// get rid of nbsp
|
|
||||||
outHtml = outHtml.replace(/ /ig, " ");
|
|
||||||
//console.log(`input html: ${html}`);
|
//console.log(`input html: ${html}`);
|
||||||
//console.log(`outpt html: ${outHtml}`);
|
//console.log(`outpt html: ${outHtml}`);
|
||||||
return outHtml;
|
return outHtml;
|
||||||
|
@ -1124,7 +1122,10 @@ class EditorWebView(AnkiWebView):
|
||||||
return self.editor.urlToLink(txt)
|
return self.editor.urlToLink(txt)
|
||||||
|
|
||||||
# normal text; convert it to HTML
|
# normal text; convert it to HTML
|
||||||
return html.escape(txt)
|
txt = html.escape(txt)
|
||||||
|
txt = txt.replace("\n", "<br>")
|
||||||
|
txt = txt.replace(" ", " ")
|
||||||
|
return txt
|
||||||
|
|
||||||
def _processHtml(self, mime):
|
def _processHtml(self, mime):
|
||||||
if not mime.hasHtml():
|
if not mime.hasHtml():
|
||||||
|
|
Loading…
Reference in a new issue