[evolution] EHTMLEditorView - Extra new line could be added to the quoted text when parsing HTML
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - Extra new line could be added to the quoted text when parsing HTML
- Date: Fri, 5 Aug 2016 14:17:46 +0000 (UTC)
commit 3522f28b49cc2f6436d9309a155e08410a807e6a
Author: Tomas Popela <tpopela redhat com>
Date: Fri Aug 5 15:39:09 2016 +0200
EHTMLEditorView - Extra new line could be added to the quoted text when parsing HTML
More specifically to the beginning of citation when the level is increased.
Also don't rely that the ##CITATION_START## mark always follow the initial BR.
e-util/e-html-editor-view.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index dfd5cc7..e899c86 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -7312,7 +7312,8 @@ remove_new_lines_around_citations (const gchar *input)
citation_type = next[11];
/* ##CITATION_START## */
if (citation_type == 'S') {
- if (g_str_has_suffix (str->str, "<br><br>"))
+ if (g_str_has_suffix (str->str, "<br><br>") ||
+ g_str_has_suffix (str->str, "<br>"))
g_string_truncate (str, str->len - 4);
if (g_str_has_prefix (next + 11, "START##<br><br>")) {
@@ -7402,10 +7403,16 @@ parse_html_into_blocks (EHTMLEditorView *view,
}
to_insert_end = g_utf8_strlen (to_process, -1);
- if ((with_br = strstr (to_process, "<br>")))
- to_insert_start += 4;
+ if ((with_br = strstr (to_process, "<br>"))) {
+ if (with_br == to_process)
+ to_insert_start += 4;
+ }
+
if ((citation_start = strstr (to_process, "##CITATION_START"))) {
- to_insert_start += 18; /* + ## */
+ if (with_br && citation_start == with_br + 4)
+ to_insert_start += 18; /* + ## */
+ else
+ to_insert_end -= 18; /* + ## */
has_citation = TRUE;
}
if ((citation_end = strstr (to_process, "##CITATION_END")))
@@ -7420,12 +7427,12 @@ parse_html_into_blocks (EHTMLEditorView *view,
block_template,
"<br id=\"-x-evo-first-br\">");
- if (with_br && citation_start)
+ if (with_br && citation_start && citation_start == with_br + 4) {
create_and_append_new_block (
selection, document, parent, block_template, "<br>");
- if (citation_start)
append_citation_mark (document, parent, "##CITATION_START##");
+ }
if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) &&
*to_insert) {
gboolean empty = FALSE;
@@ -7481,6 +7488,9 @@ parse_html_into_blocks (EHTMLEditorView *view,
g_free (to_insert);
+ if (with_br && citation_start && citation_start != with_br + 4)
+ append_citation_mark (document, parent, "##CITATION_START##");
+
if (citation_end)
append_citation_mark (document, parent, "##CITATION_END##");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]