FIX: less aggressive gmail eliding

This commit is contained in:
Régis Hanol 2018-07-04 20:04:46 +02:00
parent 448e2fe1a2
commit 8a53941fe0
2 changed files with 4 additions and 5 deletions

View File

@ -301,7 +301,7 @@ module Email
end
HTML_EXTRACTERS ||= [
[:gmail, /class="gmail_(?!default)/],
[:gmail, /class="gmail_(signature|extra)/],
[:outlook, /id="(divRplyFwdMsg|Signature)"/],
[:word, /class="WordSection1"/],
[:exchange, /name="message(Body|Reply)Section"/],
@ -313,9 +313,8 @@ module Email
]
def extract_from_gmail(doc)
# GMail adds a bunch of 'gmail_' prefixed classes like: gmail_signature, gmail_extra, gmail_quote
# Just elide them all except for 'gmail_default'
elided = doc.css("*[class^='gmail_']:not([class*='gmail_default'])").remove
# GMail adds a bunch of 'gmail_' prefixed classes like: gmail_signature, gmail_extra, gmail_quote, gmail_default...
elided = doc.css(".gmail_signature, .gmail_extra").remove
to_markdown(doc.to_html, elided.to_html)
end

View File

@ -11,7 +11,7 @@ Content-Transfer-Encoding: quoted-printable
<div dir="auto">
<p>This is a <b>GMAIL</b> reply ;)</p>
</div>
<div class="gmail_quote">
<div class="gmail_signature">
<p>This is the <i>elided</i> part!</p>
</div>
</div>