FIX: handle multiple paragraphs in email reply when parsing html

This commit is contained in:
Arpit Jalan 2014-10-08 19:45:46 +05:30
parent c46b9c0ac3
commit b457005b07
4 changed files with 12 additions and 1 deletions

View File

@ -76,7 +76,7 @@ module Email
def add_newlines(doc)
# Replace <br> tags with a markdown \n
doc.xpath('//br').each do |br|
br.replace(new_linebreak_node doc)
br.replace(new_linebreak_node doc, 2)
end
# Surround <p> tags with newlines, to help with line-wise postprocessing
# and ensure markdown paragraphs

View File

@ -82,6 +82,17 @@ Thanks for listening."
)
end
it "handles multiple paragraphs when parsing html" do
test_parse_body(fixture_file("emails/html_paragraphs.eml")).
should == (
"Awesome!
Pleasure to have you here!
:boom:"
)
end
it "converts back to UTF-8 at the end" do
result = test_parse_body(fixture_file("emails/big5.eml"))
result.encoding.should == Encoding::UTF_8

BIN
spec/fixtures/emails/html_paragraphs.eml vendored Normal file

Binary file not shown.

Binary file not shown.