Skip to content

Commit

Permalink
Update quotations.py
Browse files Browse the repository at this point in the history
Fix issue mailgun#220
cut out text lines starting from " -- forwarded messages --"
  • Loading branch information
chenxg283 authored and circlingthesun committed May 25, 2023
1 parent 77ee155 commit 55c5049
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions talon/quotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]', '', '> question'])
'tsem'
Expand Down Expand Up @@ -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'
Expand All @@ -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()]
Expand Down

0 comments on commit 55c5049

Please sign in to comment.