From b8357aa90af92da75325ea0a5f5ba43430286bee Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Thu, 26 Jun 2014 15:28:08 +1000
Subject: [PATCH] BUGFIX: newline after bold was not producting a BR

---
 .../discourse/dialects/newline_dialect.js         |  6 ++----
 spec/components/pretty_text_spec.rb               | 15 +++++++++++++++
 spec/models/post_analyzer_spec.rb                 |  4 ++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/app/assets/javascripts/discourse/dialects/newline_dialect.js b/app/assets/javascripts/discourse/dialects/newline_dialect.js
index d08a8a30f33..d53afb94f1a 100644
--- a/app/assets/javascripts/discourse/dialects/newline_dialect.js
+++ b/app/assets/javascripts/discourse/dialects/newline_dialect.js
@@ -21,10 +21,8 @@ Discourse.Dialect.postProcessText(function (text, event) {
     if (split.length) {
       var replacement = [];
       for (var i=0; i<split.length; i++) {
-        if (split[i].length > 0) {
-          replacement.push(split[i]);
-          if (i !== split.length-1) { replacement.push(['br']); }
-        }
+        if (split[i].length > 0) { replacement.push(split[i]); }
+        if (i !== split.length-1) { replacement.push(['br']); }
       }
 
       return replacement;
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index 4a6452b1a24..33fc48014b5 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -240,4 +240,19 @@ describe PrettyText do
     end
   end
 
+
+  describe "markdown quirks" do
+    it "allows for newline after bold" do
+      PrettyText.cook("**hello**\nworld").should match_html "<p><strong>hello</strong><br />world</p>"
+    end
+    it "allows for newline for 2 bolds" do
+      PrettyText.cook("**hello**\n**world**").should match_html "<p><strong>hello</strong><br /><strong>world</strong></p>"
+    end
+
+    pending "does not break a streak for mentions" do
+      Fabricate(:user, username: 'sam')
+      PrettyText.cook("<small>a @sam c</small>").should match_html "<p><small>a <a class='mention' href='/users/sam'>@sam</a> c</small></p>"
+    end
+  end
+
 end
diff --git a/spec/models/post_analyzer_spec.rb b/spec/models/post_analyzer_spec.rb
index 12f410bd3fd..92fb796fd44 100644
--- a/spec/models/post_analyzer_spec.rb
+++ b/spec/models/post_analyzer_spec.rb
@@ -5,11 +5,11 @@ describe PostAnalyzer do
   let(:default_topic_id) { 12 }
 
   describe '#cook' do
-    let(:post_analyzer) { described_class.new nil, nil  }
+    let(:post_analyzer) {PostAnalyzer.new nil, nil  }
 
-    let(:args) { [raw, options] }
     let(:raw) { "Here's a tweet:\n#{url}" }
     let(:options) { {} }
+    let(:args) { [raw, options] }
 
     let(:url) {
       'https://twitter.com/evil_trout/status/345954894420787200'