[evolution-data-server/gnome-3-38] evo-i#1206 - Mail: Preserve TABs in plain text body preview
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-38] evo-i#1206 - Mail: Preserve TABs in plain text body preview
- Date: Wed, 4 Nov 2020 10:20:14 +0000 (UTC)
commit bc59fcd18142472391f600de3ccacf746ae54ef4
Author: Milan Crha <mcrha redhat com>
Date: Wed Nov 4 11:17:06 2020 +0100
evo-i#1206 - Mail: Preserve TABs in plain text body preview
Add a new flag to cover the Evolution requirement.
Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1206
src/camel/camel-enums.h | 6 +++++-
src/camel/camel-mime-filter-tohtml.c | 24 +++++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/camel/camel-enums.h b/src/camel/camel-enums.h
index 659e9d877..3a73c9db4 100644
--- a/src/camel/camel-enums.h
+++ b/src/camel/camel-enums.h
@@ -194,6 +194,9 @@ typedef enum { /*< flags >*/
* @CAMEL_MIME_FILTER_TOHTML_DIV:
* Enclose the paragraphs in <div> ... </div> tags.
* Cannot be used together with %CAMEL_MIME_FILTER_TOHTML_PRE.
+ * @CAMEL_MIME_FILTER_TOHTML_PRESERVE_TABS:
+ * Set in combination with %CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES,
+ * to keep tab characters. If not set, converts them into the spaces.
*
* Flags for converting text/plain content into text/html.
**/
@@ -209,7 +212,8 @@ typedef enum { /*< flags >*/
CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT = 1 << 8,
CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED = 1 << 9,
CAMEL_MIME_FILTER_TOHTML_QUOTE_CITATION = 1 << 10,
- CAMEL_MIME_FILTER_TOHTML_DIV = 1 << 11
+ CAMEL_MIME_FILTER_TOHTML_DIV = 1 << 11,
+ CAMEL_MIME_FILTER_TOHTML_PRESERVE_TABS = 1 << 12
} CamelMimeFilterToHTMLFlags;
/**
diff --git a/src/camel/camel-mime-filter-tohtml.c b/src/camel/camel-mime-filter-tohtml.c
index 85254d271..8893ee1d7 100644
--- a/src/camel/camel-mime-filter-tohtml.c
+++ b/src/camel/camel-mime-filter-tohtml.c
@@ -218,11 +218,25 @@ writeln (CamelMimeFilter *mime_filter,
break;
case '\t':
if (priv->flags & (CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES)) {
- do {
- outptr = check_size (mime_filter, outptr, outend, 7);
- outptr = g_stpcpy (outptr, " ");
- priv->column++;
- } while (priv->column % 8);
+ if ((priv->flags & CAMEL_MIME_FILTER_TOHTML_PRESERVE_TABS) != 0) {
+ const gchar *tmp = "<span class=\"Apple-tab-span\"
style=\"white-space:pre\">\t</span>";
+ gint tmp_len = 61 /* strlen (tmp) */;
+ #ifdef ENABLE_MAINTAINER_MODE
+ static gboolean tested = FALSE;
+ if (!tested) {
+ tested = TRUE;
+ g_warn_if_fail (strlen (tmp) == tmp_len);
+ }
+ #endif
+ outptr = check_size (mime_filter, outptr, outend, tmp_len + 1);
+ outptr = g_stpcpy (outptr, tmp);
+ } else {
+ do {
+ outptr = check_size (mime_filter, outptr, outend, 7);
+ outptr = g_stpcpy (outptr, " ");
+ priv->column++;
+ } while (priv->column % 8);
+ }
break;
}
/* falls through */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]