[evolution] e-convert.js: Correct conversion of citations with nested blocks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] e-convert.js: Correct conversion of citations with nested blocks
- Date: Tue, 28 Apr 2020 10:18:54 +0000 (UTC)
commit e5234102b7a6c8f9e46e78616b755cc573216d52
Author: Milan Crha <mcrha redhat com>
Date: Tue Apr 28 12:20:00 2020 +0200
e-convert.js: Correct conversion of citations with nested blocks
That's for the cases when a <blockquote> contains <div> with another
<div> or <pre>, where the leading quotation marks could double.
data/webkit/e-convert.js | 23 ++++++++++++++-------
src/e-util/test-html-editor-units.c | 3 +--
src/e-util/test-web-view-jsc.c | 40 +++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 9 deletions(-)
---
diff --git a/data/webkit/e-convert.js b/data/webkit/e-convert.js
index ef5404ac1a..7211fbe022 100644
--- a/data/webkit/e-convert.js
+++ b/data/webkit/e-convert.js
@@ -657,13 +657,6 @@ EvoConvert.formatParagraph = function(str, ltr, align, indent, whiteSpace, wrapW
line = line + indent;
}
- if (quoteLevel > 0) {
- if (ltr)
- line = EvoConvert.getQuotePrefix(quoteLevel, ltr) + line;
- else
- line = line + EvoConvert.getQuotePrefix(quoteLevel, ltr);
- }
-
str += line + "\n";
}
@@ -891,6 +884,22 @@ EvoConvert.processNode = function(node, normalDivWidth, quoteLevel)
str = EvoConvert.extractElemText(node, normalDivWidth, quoteLevel + (isBlockquote ? 1
: 0));
+ if (isBlockquote) {
+ var ii, lines = str.split("\n"), prefix, suffix;
+
+ prefix = ltr ? EvoConvert.getQuotePrefix(1, ltr) : "";
+ suffix = ltr ? "" : EvoConvert.getQuotePrefix(1, ltr);
+
+ str = "";
+
+ for (ii = 0; ii < lines.length; ii++) {
+ if (ii + 1 == lines.length && !lines[ii])
+ break;
+
+ str += prefix + lines[ii] + suffix + "\n";
+ }
+ }
+
if ((!isBlockquote || !str.endsWith("\n")) &&
str != "\n" && ((style && style.display == "block") || node.tagName ==
"ADDRESS")) {
str += "\n";
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index dfd1b047b1..2dac035b63 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -6301,8 +6301,7 @@ test_pre_split_complex_html (TestFixture *fixture)
"> level 1\n"
"> E-mail: <user@no.where> line\n"
"> Phone: 1234567890\n"
- "> > div in pre\n" /* this line is level 1 in quotation, but due to nested <div> in <pre> the
EvoConvert */
- /* doubles quotation marks. It's not ideal, but it's a broken HTML anyway
(broken for the HTML editor). */
+ "> div in pre\n"
"> > level 2\n"
"> > \n"
"> > level 2\n"
diff --git a/src/e-util/test-web-view-jsc.c b/src/e-util/test-web-view-jsc.c
index dab6108109..5b0e785c2d 100644
--- a/src/e-util/test-web-view-jsc.c
+++ b/src/e-util/test-web-view-jsc.c
@@ -2910,6 +2910,46 @@ test_convert_to_plain_quoted (TestFixture *fixture)
"> paragraph 2\n"
"> paragraph 3\n"
"> paragraph 4\n",
+ 71 },
+ /* 22 */{ HTML ("<div>level 0<br><div>level 0 nested</div></div>"
+ "<blockquote type='cite'>"
+ "<div>level 1<br>"
+ "<div>level 1 nested</div></div>"
+ "<blockquote type='cite'>"
+ "<div>level 2<br>"
+ "<div>level 2 nested</div>"
+ "<div><pre>level 2 nested^2</pre></div>"
+ "<blockquote type='cite'>"
+ "<div>level 3 bq-nested<br>"
+ "<div>level 3 bq-nested nested</div></div>"
+ "</blockquote>"
+ "level 2 back</div>"
+ "<div>level 2 nested repeat</div>"
+ "</div>"
+ "<div>level 2 repeat</div>"
+ "</blockquote>"
+ "<div>level 1 back<br>"
+ "<div>level 1 repeat - nested</div></div>"
+ "<div>level 1 repeat</div>"
+ "</blockquote>"
+ "<div>level 0 back<br><div>level 0 back nested</div></div>"),
+ "level 0\n"
+ "level 0 nested\n"
+ "> level 1\n"
+ "> level 1 nested\n"
+ "> > level 2\n"
+ "> > level 2 nested\n"
+ "> > level 2 nested^2\n"
+ "> > > level 3 bq-nested\n"
+ "> > > level 3 bq-nested nested\n"
+ "> > level 2 back\n"
+ "> > level 2 nested repeat\n"
+ "> > level 2 repeat\n"
+ "> level 1 back\n"
+ "> level 1 repeat - nested\n"
+ "> level 1 repeat\n"
+ "level 0 back\n"
+ "level 0 back nested\n",
71 }
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]