diff --git a/talon/html_quotations.py b/talon/html_quotations.py index 735f189..261232e 100644 --- a/talon/html_quotations.py +++ b/talon/html_quotations.py @@ -78,7 +78,7 @@ def delete_quotation_tags(html_note, counter, quotation_checkpoints): def cut_gmail_quote(html_message): ''' Cuts the outermost block element with class gmail_quote. ''' gmail_quote = html_message.cssselect('div.gmail_quote') - if gmail_quote and not RE_FWD.match(gmail_quote[0].text): + if gmail_quote and (gmail_quote[0].text is None or not RE_FWD.match(gmail_quote[0].text)): gmail_quote[0].getparent().remove(gmail_quote[0]) return True diff --git a/tests/html_quotations_test.py b/tests/html_quotations_test.py index 665dbc1..1658fe7 100644 --- a/tests/html_quotations_test.py +++ b/tests/html_quotations_test.py @@ -131,6 +131,17 @@ def test_gmail_quote(): RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body))) +def test_gmail_quote_compact(): + msg_body = 'Reply' \ + '
' \ + '
On 11-Apr-2011, at 6:54 PM, Bob <bob@example.com> wrote:' \ + '
Test
' \ + '
' \ + '
' + eq_("

Reply

", + RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body))) + + def test_gmail_quote_blockquote(): msg_body = """Message