From 4331bba54958f78c97a6cd833f7671ff89c187d5 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 3 Jul 2013 18:25:38 -0400 Subject: [PATCH] FIX: Quotes with text against them had the wrong spacing --- app/assets/javascripts/discourse/components/markdown.js | 5 +++++ test/javascripts/components/markdown_test.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/markdown.js b/app/assets/javascripts/discourse/components/markdown.js index 373df516c..14b64a244 100644 --- a/app/assets/javascripts/discourse/components/markdown.js +++ b/app/assets/javascripts/discourse/components/markdown.js @@ -102,6 +102,11 @@ Discourse.Markdown = { var quoteTemplate = null, urlsTemplate = null; // Before cooking callbacks + converter.hooks.chain("preConversion", function(text) { + // If a user puts text right up against a quote, make sure the spacing is equivalnt to a new line + return text.replace(/\[\/quote\]/, "[/quote]\n"); + }); + converter.hooks.chain("preConversion", function(text) { Discourse.Markdown.trigger('beforeCook', { detail: text, opts: opts }); return Discourse.Markdown.textResult || text; diff --git a/test/javascripts/components/markdown_test.js b/test/javascripts/components/markdown_test.js index 2b6d7c9f8..0b44cec4c 100644 --- a/test/javascripts/components/markdown_test.js +++ b/test/javascripts/components/markdown_test.js @@ -69,13 +69,13 @@ test("Quotes", function() { cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function(name) { return "" + name; } }, "

1

\n


\n2

", + " bob\n bob\n said:\n \n
my quote
\n\n

\n\n

2

", "handles quotes properly"); cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function(name) { } }, "

1

\n


\n2

", + " \n bob\n said:\n \n
my quote
\n\n

\n\n

2

", "includes no avatar if none is found"); });