aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-04-19 22:37:05 +0800
committerDan Winship <danw@src.gnome.org>2001-04-19 22:37:05 +0800
commita50c888bbeec17fc4cd8e18764375a28be2a0b90 (patch)
treedf0a2b42e18294411a2fd46889b8b5b076a137a5 /e-util
parentf01019286633b42afb08fa4449e16c4ca0aba848 (diff)
downloadgsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar.gz
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar.bz2
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar.lz
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar.xz
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.tar.zst
gsoc2013-evolution-a50c888bbeec17fc4cd8e18764375a28be2a0b90.zip
">From" is not a citation unless the previous or following line is a
* e-html-utils.c (is_citation): ">From" is not a citation unless the previous or following line is a citation. (e_text_to_html_full): Update for is_citation change. Also, when marking citations, unmangle mbox From-mangling. svn path=/trunk/; revision=9458
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog7
-rw-r--r--e-util/e-html-utils.c44
2 files changed, 44 insertions, 7 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index e2ec41daa4..250499876e 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,10 @@
+2001-04-19 Dan Winship <danw@ximian.com>
+
+ * e-html-utils.c (is_citation): ">From" is not a citation unless
+ the previous or following line is a citation.
+ (e_text_to_html_full): Update for is_citation change. Also, when
+ marking citations, unmangle mbox From-mangling.
+
2001-04-15 Federico Mena Quintero <federico@ximian.com>
* e-sexp.c (e_sexp_parse): Start parsing the sexp with
diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c
index 0a1938f0fa..4bcfc920b0 100644
--- a/e-util/e-html-utils.c
+++ b/e-util/e-html-utils.c
@@ -114,12 +114,37 @@ email_address_extract (const unsigned char **text)
}
static gboolean
-is_citation (const unsigned char *c)
+is_citation (const unsigned char *c, gboolean saw_citation)
{
unicode_char_t u;
gint i;
- for (i = 0; c && *c && i < 10; i ++, c = unicode_next_utf8 (c)) {
+ /* A line that starts with a ">" is a citation, unless it's
+ * just mbox From-mangling...
+ */
+ if (*c == '>') {
+ const unsigned char *p;
+
+ if (strncmp (c, ">From ", 6) != 0)
+ return TRUE;
+
+ /* If the previous line was a citation, then say this
+ * one is too.
+ */
+ if (saw_citation)
+ return TRUE;
+
+ /* Same if the next line is */
+ p = (const unsigned char *)strchr ((const char *)c, '\n');
+ if (p && *++p == '>')
+ return TRUE;
+
+ /* Otherwise, it was just an isolated ">From" line. */
+ return FALSE;
+ }
+
+ /* Check for "Rupert> " and the like... */
+ for (i = 0; c && *c && *c != '\n' && i < 10; i ++, c = unicode_next_utf8 (c)) {
unicode_get_utf8 (c, &u);
if (u == '>')
return TRUE;
@@ -166,8 +191,8 @@ is_citation (const unsigned char *c)
* - E_TEXT_TO_HTML_CONVERT_ADDRESSES: wrap <a href="mailto:..."> </a> around
* strings that look like mail addresses.
*
- * - E_TEXT_TO_HTML_MARK_CITATION: wrap <font color="blue"> </font> around
- * citations (lines beginning with "> ").
+ * - E_TEXT_TO_HTML_MARK_CITATION: wrap <font color="..."> </font> around
+ * citations (lines beginning with "> ", etc).
**/
char *
e_text_to_html_full (const char *input, unsigned int flags, guint32 color)
@@ -176,7 +201,7 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color)
char *buffer = NULL;
char *out = NULL;
int buffer_size = 0, col;
- gboolean colored = FALSE;
+ gboolean colored = FALSE, saw_citation = FALSE;
/* Allocate a translation buffer. */
buffer_size = strlen (input) * 2 + 5;
@@ -191,9 +216,9 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color)
for (cur = input; cur && *cur; cur = unicode_next_utf8 (cur)) {
unicode_char_t u;
- unicode_get_utf8 (cur, &u);
if (flags & E_TEXT_TO_HTML_MARK_CITATION && col == 0) {
- if (is_citation (cur)) {
+ saw_citation = is_citation (cur, saw_citation);
+ if (saw_citation) {
if (!colored) {
gchar font [25];
@@ -210,8 +235,13 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color)
out += sprintf (out, "%s", no_font);
colored = FALSE;
}
+
+ /* Display mbox-mangled ">From" as "From" */
+ if (*cur == '>' && !saw_citation)
+ cur++;
}
+ unicode_get_utf8 (cur, &u);
if (unicode_isalpha (u) &&
(flags & E_TEXT_TO_HTML_CONVERT_URLS)) {
char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL;