From bea93f95cb1ec338c3efff95407e6476996ec35d Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Mon, 30 Jun 2014 14:31:25 +0200 Subject: EHTMLEditorView - Refactor the code that triggers the surround of links with anchor elements And add www to patterns. --- e-util/e-html-editor-view.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index 45dc747d67..56ec293b1a 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -3362,6 +3362,13 @@ replace_to_nbsp (const GMatchInfo *info, return FALSE; } +static gboolean +surround_links_with_anchor (const gchar *text) +{ + return (strstr (text, "http") || strstr (text, "ftp") || + strstr (text, "www") || strstr (text, "@")); +} + /* This parses the HTML code (that contains just text,   and BR elements) * into paragraphs. * HTML code in that format we can get by taking innerText from some element, @@ -3480,9 +3487,7 @@ parse_html_into_paragraphs (EHTMLEditorView *view, NULL); g_free (truncated); - if (strstr (rest_to_insert, "http") || - strstr (rest_to_insert, "ftp") || - strstr (rest_to_insert, "@")) { + if (surround_links_with_anchor (rest_to_insert)) { truncated = g_regex_replace_eval ( regex_links, rest_to_insert, @@ -3543,9 +3548,7 @@ parse_html_into_paragraphs (EHTMLEditorView *view, NULL); g_free (truncated); - if (strstr (rest_to_insert, "http") || - strstr (rest_to_insert, "ftp") || - strstr (rest_to_insert, "@")) { + if (surround_links_with_anchor (rest_to_insert)) { truncated = g_regex_replace_eval ( regex_links, rest_to_insert, -- cgit v1.2.3