forked from closeio/quotequail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image in beginning of reply is incorrectly ignored. Fix. Originally reported in closeio#22 and solved by @andreip in closeio#26 In his words: "Couldn't think of a different approach, since an img isn't really a block, so it'll never have a text within it, so no point in generating a different html in get_line_info functions. Instead, what was missing was it being treated as a special case: don't want to slice a line from the HTML by just looking at the plain text lines, since that could slice an img, need to also look at the start/end refs for replaced tags. See more about a replaced element (https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element). I think it might be worth adding a few more things to the list? e.g. video, embed etc. ; not sure about iframe and how that'd be treated in lxml parsing though, but I suppose you could have an iframe with just an image in it, in which case you'd still want to keep it? Full list would be a total of 9 replaced elements (or 10 if we also count input; although I'm not sure of all examples where that'd generate sth even if it apparently has no text in it)."
- Loading branch information
1 parent
426b517
commit d26bd16
Showing
3 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -949,6 +949,19 @@ def test_gmail_reply(self): | |
}, | ||
) | ||
|
||
def test_reply_with_image(self): | ||
html = 'Test 2.<br><br>On Jun 05, 2018, at 09:56 AM, John Doe <[email protected]> wrote:<br><blockquote><img src="https://example.com" class="fr-fic fr-dib"><br>Some text 1.<br><br>Bart</blockquote>' | ||
self.assertEqual( | ||
unwrap_html(html), | ||
{ | ||
"date": "Jun 05, 2018, at 09:56 AM", | ||
"from": "John Doe <[email protected]>", | ||
"html": u'<div><img src="https://example.com" class="fr-fic fr-dib"><br>Some text 1.<br><br>Bart</div>', | ||
"html_top": u"Test 2.", | ||
"type": "reply", | ||
}, | ||
) | ||
|
||
def test_outlook_forward(self): | ||
data = self.read_file("outlook_forward.html") | ||
result = unwrap_html(data) | ||
|