From 99f25bfd883c4fabc145618937662b6abecf321d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 17 Dec 2009 19:52:01 -0500 Subject: [PATCH] TracZephyrPlugin: Smarter quoted text regex. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some mail clients quote an empty line as ‘>’ instead of ‘> ’. Also check that at least one of the quoted lines is nonempty. Signed-off-by: Anders Kaseorg --- TracZephyrPlugin/ZephyrPlugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TracZephyrPlugin/ZephyrPlugin.py b/TracZephyrPlugin/ZephyrPlugin.py index 45584ae..679d019 100644 --- a/TracZephyrPlugin/ZephyrPlugin.py +++ b/TracZephyrPlugin/ZephyrPlugin.py @@ -7,6 +7,8 @@ import re import textwrap import shlex +quoted_re = re.compile('^(?:> ?\n)*> .+\n(?:>(?: .*)?\n)*', re.MULTILINE) + class ZephyrPlugin(Component): implements(ITicketChangeListener) @@ -26,7 +28,7 @@ class ZephyrPlugin(Component): p.wait() def format_text(self, text): - text = re.sub(re.compile('^(?:> .*\n)+', re.MULTILINE), u'> […]\n', text) + text = re.sub(quoted_re, u'> […]\n', text) lines = textwrap.fill(text).split('\n') if len(lines) > 5: lines = lines[:5] + [u'[…]'] -- 2.44.0