Skip to content

Commit

Permalink
Merge pull request #4 from Easy-D/preserve-regular-blockquotes-claw
Browse files Browse the repository at this point in the history
Preserve regular blockquotes
  • Loading branch information
tgwizard committed Aug 25, 2015
2 parents f2a2229 + 36c0d39 commit 07dade1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 4 additions & 3 deletions claw/html_quotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ def cut_by_id(html_message):


def cut_blockquote(html_message):
''' Cuts blockquote with wrapping elements. '''
quote = html_message.find('.//blockquote')
if quote is not None:
''' Cuts the last non-nested blockquote with wrapping elements. '''
quote = html_message.xpath('(.//blockquote)[not(ancestor::blockquote)][last()]')
if quote:
quote = quote[0]
quote.getparent().remove(quote)
return True

Expand Down
18 changes: 18 additions & 0 deletions tests/html_quotations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def test_quotation_splitter_outside_blockquote():
RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body)))


def test_regular_blockquote():
msg_body = """Reply
<blockquote>Regular</blockquote>
<div>
On 11-Apr-2011, at 6:54 PM, Bob &lt;bob@example.com&gt; wrote:
</div>
<blockquote>
<div>
<blockquote>Nested</blockquote>
</div>
</blockquote>
"""
eq_("<html><body><p>Reply</p><blockquote>Regular</blockquote><div></div></body></html>",
RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body)))


def test_no_blockquote():
msg_body = """
<html>
Expand Down

0 comments on commit 07dade1

Please sign in to comment.