diff --git a/lib/email/html_cleaner.rb b/lib/email/html_cleaner.rb
index b4333ae91..96f6d313e 100644
--- a/lib/email/html_cleaner.rb
+++ b/lib/email/html_cleaner.rb
@@ -76,7 +76,7 @@ module Email
def add_newlines(doc)
# Replace
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
tags with newlines, to help with line-wise postprocessing
# and ensure markdown paragraphs
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb
index 32babee20..41a588064 100644
--- a/spec/components/email/receiver_spec.rb
+++ b/spec/components/email/receiver_spec.rb
@@ -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
diff --git a/spec/fixtures/emails/html_paragraphs.eml b/spec/fixtures/emails/html_paragraphs.eml
new file mode 100644
index 000000000..3fe37fb8b
--- /dev/null
+++ b/spec/fixtures/emails/html_paragraphs.eml
@@ -0,0 +1,205 @@
+
+MIME-Version: 1.0
+Received: by 10.25.161.144 with HTTP; Tue, 7 Oct 2014 22:17:17 -0700 (PDT)
+X-Originating-IP: [117.207.85.84]
+In-Reply-To: <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
+References: Nice to be here! Thanks! To respond, reply to this email or visit http://discourse=
+.techapj.com/t/welcome-to-techapjs-discourse/35/2 in your browser. Welcome to techAPJ's Discourse! To respond, reply to this email or visit http://discourse.tec=
+hapj.com/t/welcome-to-techapjs-discourse/35/2 in your browser. To unsubscribe from these emails, visit your user preferences.
+
+
+
+
+
+
+
+
+
+
+ ajalan
+
+ October 8
+
+
+
+
+
+ Previous Replies
+
+
+
+
+
+
+
+
+
+
+
+
+ techAPJ
+
+ October 8
+
+
+
+
+
+
+