diff options
| author | Milan Crha <mcrha@redhat.com> | 2020-11-04 11:17:06 +0100 |
|---|---|---|
| committer | Milan Crha <mcrha@redhat.com> | 2020-11-04 11:17:06 +0100 |
| commit | 581e6f877d8af71b701ffea2e1281226722eade2 (patch) | |
| tree | 7f521913aee8c01a3fa8f5291753c07c2304e724 | |
| parent | ccde3df1614c872cdd87a1d0d3e6cb4b7a0701d5 (diff) | |
| download | evolution-data-server-581e6f877d8af71b701ffea2e1281226722eade2.tar.gz | |
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
| -rw-r--r-- | src/camel/camel-enums.h | 6 | ||||
| -rw-r--r-- | 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 */ |
