FEATURE: begone gmail signatures!

This commit is contained in:
Régis Hanol 2018-02-27 15:19:34 +01:00
parent 73ee62f55f
commit 3c430a3949
1 changed files with 4 additions and 4 deletions

View File

@ -261,7 +261,7 @@ module Email
end
markdown, elided_markdown = if html.present?
if html[/<div class="gmail_(quote|extra)"/]
if html[%{<div class="gmail_}]
html, elided_html = extract_from_gmail(html)
markdown = HtmlToMarkdown.new(html, keep_img_tags: true, keep_cid_imgs: true).to_markdown
elided_markdown = HtmlToMarkdown.new(elided_html).to_markdown
@ -286,9 +286,9 @@ module Email
end
def extract_from_gmail(html)
doc = Nokogiri::HTML.fragment(html)
elided = doc.css(".gmail_quote, .gmail_extra").remove
[doc.to_html, elided.to_html]
doc = Nokogiri::HTML.parse(html)
elided = doc.xpath("//*[contains(@class, 'gmail_')]").remove
[doc.root.to_html, elided.to_html]
end
def extract_from_outlook(html)