Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
better handling of newlines which should hopefully eliminate new line duplication
azivnerbf22cc55e17c
diff --git a/static/js/html2notecase.js b/static/js/html2notecase.jsindex e2de650120..0241175cd6 100644--- a/static/js/html2notecase.js+++ b/static/js/html2notecase.js@@ -1,7 +1,11 @@function html2notecase(contents, note) {+ //console.log("'" + contents + "'");+// remove any possible extra newlines which might be inserted - all relevant new lines should be only in <br> and <p>contents = contents.replace(/(?:\r\n|\r|\n)/, '');+ contents = contents.replace(/<br><\/p>/g, '\n');+ contents = contents.replace(/<p><br><\/p>/g, '\n');contents = contents.replace(/<br \/>/g, '\n');contents = contents.replace(/<br>/g, '\n');contents = contents.replace(/<\/p>/g, '\n');@@ -144,7 +148,9 @@ function html2notecase(contents, note) {}}- //console.log(contents);+ contents = contents.trim();++ //console.log('"' + contents + '"');note.detail.note_text = contents;}\ No newline at end of filediff --git a/static/js/notecase2html.js b/static/js/notecase2html.jsindex 54e56c721f..c4d66f9f76 100644--- a/static/js/notecase2html.js+++ b/static/js/notecase2html.js@@ -43,7 +43,11 @@ function notecase2html(note) {}}- noteText = noteText.replace(/(?:\r\n|\r|\n)/g, '<br />');+ noteText = noteText.replace(/(?:\r\n|\r)/g, '\n');++ noteText = noteText.replace(/(.+)\n/g, '<p>$1</p>');++ noteText = noteText.replace(/\n/g, '<p><br></p>');noteText = noteText.replace(/ /g, ' ');