From bd99b258481d5519e7ee84079e99f758984584ee Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 10 Apr 2020 17:12:41 +0000 Subject: [PATCH] Desktop: WYSIWYG: Preserve HTML code in Markdown when editing from wysiwyg editor --- CliClient/package-lock.json | 49 ++++++++++----- CliClient/package.json | 2 +- CliClient/tests/html_to_md/html_in_md.html | 6 ++ CliClient/tests/html_to_md/html_in_md.md | 9 +++ CliClient/tests/md_to_html/html_in_md.html | 4 ++ CliClient/tests/md_to_html/html_in_md.md | 4 ++ CliClient/tests/md_to_html/sanitize.html | 4 +- CliClient/tests/md_to_html/sanitize_10.html | 2 +- CliClient/tests/md_to_html/sanitize_2.html | 2 +- CliClient/tests/md_to_html/sanitize_3.html | 2 +- CliClient/tests/md_to_html/sanitize_4.html | 2 +- CliClient/tests/md_to_html/sanitize_5.html | 2 +- CliClient/tests/md_to_html/sanitize_6.html | 2 +- CliClient/tests/md_to_html/sanitize_9.html | 2 +- ElectronClient/gui/NoteText2.tsx | 11 ++++ ElectronClient/gui/editors/TinyMCE.tsx | 2 +- ElectronClient/package-lock.json | 60 +++++++++++++------ ElectronClient/package.json | 2 +- .../MdToHtml/rules/sanitize_html.ts | 2 +- .../lib/joplin-renderer/htmlUtils.js | 17 +++++- .../lib/joplin-renderer/tests/MdToHtmlTest.js | 24 -------- 21 files changed, 139 insertions(+), 71 deletions(-) create mode 100644 CliClient/tests/html_to_md/html_in_md.html create mode 100644 CliClient/tests/html_to_md/html_in_md.md create mode 100644 CliClient/tests/md_to_html/html_in_md.html create mode 100644 CliClient/tests/md_to_html/html_in_md.md delete mode 100644 ReactNativeClient/lib/joplin-renderer/tests/MdToHtmlTest.js diff --git a/CliClient/package-lock.json b/CliClient/package-lock.json index 704f86fb2..c02fc2576 100644 --- a/CliClient/package-lock.json +++ b/CliClient/package-lock.json @@ -2111,7 +2111,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2132,12 +2133,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2152,17 +2155,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2279,7 +2285,8 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2291,6 +2298,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2305,6 +2313,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2312,12 +2321,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2336,6 +2347,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2425,7 +2437,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2437,6 +2450,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2522,7 +2536,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2558,6 +2573,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2577,6 +2593,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2620,12 +2637,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -3730,9 +3749,9 @@ "dev": true }, "joplin-turndown": { - "version": "4.0.24", - "resolved": "https://registry.npmjs.org/joplin-turndown/-/joplin-turndown-4.0.24.tgz", - "integrity": "sha512-mKd2rAFzJKnhTVjEpHomG+T01//uz5rXVSAOYRh3/JKXpY7QUhVp8jCmFfO+kaadrLABTz04mvTmyyoOadxdTA==", + "version": "4.0.27", + "resolved": "https://registry.npmjs.org/joplin-turndown/-/joplin-turndown-4.0.27.tgz", + "integrity": "sha512-qwJEzpbsyXnfjYgCVXWbuf3BdbDAaP7edm5ubeVAaQ3RnaiSEB2xZLg3lubmuFOIxXnkMDMkGJC4G+qAbCW95w==", "requires": { "css": "^2.2.4", "html-entities": "^1.2.1", @@ -6590,7 +6609,7 @@ "requires": { "chalk": "^2.1.0", "emphasize": "^1.5.0", - "node-emoji": "git+https://github.com/laurent22/node-emoji.git#9fa01eac463e94dde1316ef8c53089eeef4973b5", + "node-emoji": "git+https://github.com/laurent22/node-emoji.git", "slice-ansi": "^1.0.0", "string-width": "^2.1.1", "terminal-kit": "^1.13.11", diff --git a/CliClient/package.json b/CliClient/package.json index 6d0e666b1..e4973af59 100644 --- a/CliClient/package.json +++ b/CliClient/package.json @@ -55,7 +55,7 @@ "htmlparser2": "^4.1.0", "image-data-uri": "^2.0.0", "image-type": "^3.0.0", - "joplin-turndown": "^4.0.24", + "joplin-turndown": "^4.0.27", "joplin-turndown-plugin-gfm": "^1.0.12", "json-stringify-safe": "^5.0.1", "jssha": "^2.3.0", diff --git a/CliClient/tests/html_to_md/html_in_md.html b/CliClient/tests/html_to_md/html_in_md.html new file mode 100644 index 000000000..4b37317cd --- /dev/null +++ b/CliClient/tests/html_to_md/html_in_md.html @@ -0,0 +1,6 @@ +

Line 1

+
Line 2
+
Line 4
+
Line 5
+

Line 6

+
Markdown inside
\ No newline at end of file diff --git a/CliClient/tests/html_to_md/html_in_md.md b/CliClient/tests/html_to_md/html_in_md.md new file mode 100644 index 000000000..7c92246ea --- /dev/null +++ b/CliClient/tests/html_to_md/html_in_md.md @@ -0,0 +1,9 @@ +Line 1 + +
Line 2
Line 4
+ +Line 5 + +Line 6 + +
Markdown **inside**
\ No newline at end of file diff --git a/CliClient/tests/md_to_html/html_in_md.html b/CliClient/tests/md_to_html/html_in_md.html new file mode 100644 index 000000000..2f9323ff0 --- /dev/null +++ b/CliClient/tests/md_to_html/html_in_md.html @@ -0,0 +1,4 @@ +

Line 1

+
Line 2
+
Line 4
+Line 5 \ No newline at end of file diff --git a/CliClient/tests/md_to_html/html_in_md.md b/CliClient/tests/md_to_html/html_in_md.md new file mode 100644 index 000000000..3aad8dd46 --- /dev/null +++ b/CliClient/tests/md_to_html/html_in_md.md @@ -0,0 +1,4 @@ +Line 1 +
Line 2
+
Line 4
+Line 5 \ No newline at end of file diff --git a/CliClient/tests/md_to_html/sanitize.html b/CliClient/tests/md_to_html/sanitize.html index 7f871c790..0b7bbba7b 100644 --- a/CliClient/tests/md_to_html/sanitize.html +++ b/CliClient/tests/md_to_html/sanitize.html @@ -1,2 +1,2 @@ - - \ No newline at end of file + + \ No newline at end of file diff --git a/CliClient/tests/md_to_html/sanitize_10.html b/CliClient/tests/md_to_html/sanitize_10.html index d75c322f2..f99f6f8d0 100644 --- a/CliClient/tests/md_to_html/sanitize_10.html +++ b/CliClient/tests/md_to_html/sanitize_10.html @@ -1,4 +1,4 @@ -