From 55c504987407c75288d076463d82fb17a481abfc Mon Sep 17 00:00:00 2001 From: chenxg283 Date: Thu, 15 Jul 2021 10:22:58 +0800 Subject: [PATCH] Update quotations.py Fix issue #220 cut out text lines starting from " -- forwarded messages --" --- talon/quotations.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/talon/quotations.py b/talon/quotations.py index b244c6c..7e8574d 100644 --- a/talon/quotations.py +++ b/talon/quotations.py @@ -234,6 +234,7 @@ def mark_message_lines(lines): * m - line that starts with quotation marker '>' * s - splitter line * t - presumably lines from the last message in the conversation + * f - forwarded message line >>> mark_message_lines(['answer', 'From: foo@bar.com', '', '> question']) 'tsem' @@ -283,9 +284,9 @@ def process_marked_lines(lines, markers, return_flags=[False, -1, -1]): if 's' not in markers and not re.search('(me*){3}', markers): markers = markers.replace('m', 't') - if re.match('[te]*f', markers): - return_flags[:] = [False, -1, -1] - return lines + # if re.match('[te]*f', markers): + # return_flags[:] = [False, -1, -1] + # return lines # inlined reply # use lookbehind assertions to find overlapping entries e.g. for 'mtmtm' @@ -300,8 +301,8 @@ def process_marked_lines(lines, markers, return_flags=[False, -1, -1]): return_flags[:] = [False, -1, -1] return lines - # cut out text lines coming after splitter if there are no markers there - quotation = re.search('(se*)+((t|f)+e*)+', markers) + # cut out text lines coming after splitter or forwarded message line if there are no markers there + quotation = re.search('((se*)+((t|f)+e*)+|f)', markers) if quotation: return_flags[:] = [True, quotation.start(), len(lines)] return lines[:quotation.start()]