diff options
author | Tomas Popela <tpopela@redhat.com> | 2014-07-15 16:52:20 +0800 |
---|---|---|
committer | Tomas Popela <tpopela@redhat.com> | 2014-07-15 17:10:00 +0800 |
commit | 127d946dffef95579d68cb195ec0b06f6032fcd9 (patch) | |
tree | 178abea0cf35e9d21a14b69814e16a93cd500ca1 | |
parent | 12be2b0114f7249ccd7ec02e4907edc7a8adaea1 (diff) | |
download | gsoc2013-evolution-127d946dffef95579d68cb195ec0b06f6032fcd9.tar.gz gsoc2013-evolution-127d946dffef95579d68cb195ec0b06f6032fcd9.tar.zst gsoc2013-evolution-127d946dffef95579d68cb195ec0b06f6032fcd9.zip |
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.
-rw-r--r-- | 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 3ab77673fc..0c5c04147e 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), |