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: + <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail> +Date: Wed, 8 Oct 2014 10:47:17 +0530 +Delivered-To: arpit@techapj.com +Message-ID: +Subject: Re: [Discourse] [Meta] Welcome to techAPJ's Discourse! +From: Arpit Jalan +To: Discourse +Content-Type: multipart/alternative; boundary=001a114119d8f4e46e0504e26d5b + +--001a114119d8f4e46e0504e26d5b +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Awesome! + +Pleasure to have you here! + +:boom: + +On Wed, Oct 8, 2014 at 10:46 AM, ajalan +wrote: + +> ajalan +> +> October 8 +> +> Nice to be here! Thanks! [image: smile] +> +> To respond, reply to this email or visit +> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2 +> +> in your browser. +> ------------------------------ +> Previous Replies techAPJ +> +> October 8 +> +> Welcome to techAPJ's Discourse! +> ------------------------------ +> +> To respond, reply to this email or visit +> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2 +> +> in your browser. +> +> To unsubscribe from these emails, visit your user preferences +> +> . +> + +--001a114119d8f4e46e0504e26d5b +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +

Awesome!

Pleasure to have you here!

:boom:

On Wed, Oct 8, 2014 at 10:46 AM, ajalan <info@unconfigured.discourse.org> wrote:
+ + + + + + + + + + + +
+ + + ajalan
+ October 8 +

Nice to be here! Thanks! 3D"smile"

+ + +
+

To respond, reply to this email or visit http://discourse= +.techapj.com/t/welcome-to-techapjs-discourse/35/2 in your browser.

+
+
+

Previous Replies

+ + + + + + + + + + + +
+ + + techAPJ
+ October 8 +

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.

+
+
+ +
= +
+ +--001a114119d8f4e46e0504e26d5b-- diff --git a/spec/fixtures/emails/paragraphs.eml b/spec/fixtures/emails/paragraphs.eml index c34972418..2d5b5283f 100644 --- a/spec/fixtures/emails/paragraphs.eml +++ b/spec/fixtures/emails/paragraphs.eml @@ -39,4 +39,4 @@ On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta > Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3 > > To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences). -> \ No newline at end of file +>