[Xfce4-commits] <postler:master> Don't show quotes longer than 5 lines

Christian Dywan noreply at xfce.org
Sun Jul 10 20:30:02 CEST 2011


Updating branch refs/heads/master
         to 6883460388d165d1057830624ec03f1e18b0ff08 (commit)
       from dfc21091f888c3f7e372540534dbc30fb7c86ccf (commit)

commit 6883460388d165d1057830624ec03f1e18b0ff08
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jul 10 20:27:04 2011 +0200

    Don't show quotes longer than 5 lines

 postler/postler-content.vala |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 415155e..fb371a6 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -911,6 +911,7 @@ public class Postler.Content : WebKit.WebView {
     string render_plain_text (string body, string? project) {
         bool in_signature = false;
         int in_quote = 0;
+        int quoted_line_count = 0;
 
         var new_body = new StringBuilder ("");
         if (project != null)
@@ -939,13 +940,22 @@ public class Postler.Content : WebKit.WebView {
                     position++;
                 } while (true);
 
-                if (quote_mark < in_quote)
-                    new_body.append ("</blockquote>");
+                if (quote_mark < in_quote) {
+                    /* Don't add empty quote blocks */
+                    if (new_body.str.has_suffix ("<blockquote>"))
+                        new_body.truncate (new_body.len - 12);
+                    else
+                        new_body.append ("</blockquote>");
+                }
                 else if (quote_mark > in_quote) {
                     for (int i = in_quote; i < quote_mark; i++)
                         new_body.append ("<blockquote>");
                 }
                 in_quote = quote_mark;
+                if (in_quote > 0)
+                    quoted_line_count++;
+                else
+                    quoted_line_count = 0;
             }
 
             if (in_quote > 0 && line[0] == '>' && line[1] == ' ') {
@@ -960,7 +970,10 @@ public class Postler.Content : WebKit.WebView {
             }
             else if (in_quote > 0 && line[0] == '>' && line[1] == '\0')
                 line = line.substring (1);
-            new_body.append (line + "<br>");
+
+            /* Don't show quotes longer than 5 lines */
+            if (line.contains ("blockquote>") || quoted_line_count < 5)
+                new_body.append (line + "<br>");
         }
         if (project != null)
             new_body.append ("</span");



More information about the Xfce4-commits mailing list