[evolution/wip/webkit2] 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/wip/webkit2] EHTMLEditorView - Extra new line could be added to the quoted text when parsing HTML
- Date: Fri, 5 Aug 2016 14:24:46 +0000 (UTC)
commit c430894c8610be328d262ab857ca803062fbf860
Author: Tomas Popela <tpopela redhat com>
Date: Fri Aug 5 16:21:46 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.
.../web-extension/e-editor-dom-functions.c | 21 ++++++++++++++-----
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index eea8342..6cbe630 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -5039,7 +5039,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><br>"))
g_string_truncate (str, str->len - 4);
if (g_str_has_prefix (next + 11, "START##<br><br>")) {
@@ -5129,10 +5130,15 @@ parse_html_into_blocks (EEditorPage *editor_page,
}
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")))
@@ -5143,12 +5149,12 @@ parse_html_into_blocks (EEditorPage *editor_page,
create_and_append_new_block (
editor_page, parent, 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 (
editor_page, 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;
@@ -5204,6 +5210,9 @@ parse_html_into_blocks (EEditorPage *editor_page,
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]