[evolution] EHTMLEditorView - Don't lose the empty lines when converting HTML to plain text
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - Don't lose the empty lines when converting HTML to plain text
- Date: Tue, 15 Jul 2014 09:10:38 +0000 (UTC)
commit 127d946dffef95579d68cb195ec0b06f6032fcd9
Author: Tomas Popela <tpopela redhat com>
Date: Tue Jul 15 10:52:20 2014 +0200
EHTMLEditorView - Don't lose the empty lines when converting HTML to plain text
Namely don't lose the new line on the beginning or on the end of
processed content and also on the lines with zero width space character.
e-util/e-html-editor-view.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 3ab7767..0c5c041 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -3419,6 +3419,7 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
GString *start, *end;
gboolean ignore_next_br = FALSE;
GRegex *regex_nbsp = NULL, *regex_links = NULL;
+ gboolean first_element = TRUE;
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (blockquote), "", NULL);
@@ -3540,23 +3541,38 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
*rest_to_insert ? rest_to_insert : "<br>",
NULL);
+ if (g_strcmp0 (rest_to_insert, UNICODE_ZERO_WIDTH_SPACE) == 0)
+ webkit_dom_html_element_set_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (paragraph), "<br>", NULL);
+
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (blockquote),
WEBKIT_DOM_NODE (paragraph),
NULL);
g_free (rest_to_insert);
+ } else if (rest && !*rest && first_element) {
+ webkit_dom_html_element_set_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (paragraph),
+ "<br class=\"-x-evo-first-br\">",
+ NULL);
+
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (blockquote),
+ WEBKIT_DOM_NODE (paragraph),
+ NULL);
}
if (citation_end)
ignore_next_br = TRUE;
+ first_element = FALSE;
prev_br = next_br;
next_br = strstr (prev_br + 4, "<br>");
g_free (to_insert);
}
- if (g_utf8_strlen (prev_br, -1) > 0 && (g_strcmp0 (prev_br, "<br>") != 0)) {
+ if (g_utf8_strlen (prev_br, -1) > 0) {
gchar *truncated = g_strdup (
g_str_has_prefix (prev_br, "<br>") ? prev_br + 4 : prev_br);
gchar *rest_to_insert;
@@ -3598,9 +3614,16 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (paragraph),
- *rest_to_insert ? rest_to_insert : "<br>",
+ *rest_to_insert ?
+ rest_to_insert : "<br class=\"-x-evo-last-br\">",
NULL);
+ if (g_strcmp0 (rest_to_insert, UNICODE_ZERO_WIDTH_SPACE) == 0)
+ webkit_dom_html_element_set_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (paragraph),
+ "<br class=\"-x-evo-last-br\">",
+ NULL);
+
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (blockquote),
WEBKIT_DOM_NODE (paragraph),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]