diff --git a/app/assets/javascripts/discourse/dialects/quote_dialect.js b/app/assets/javascripts/discourse/dialects/quote_dialect.js
index 3b8f0003ef..6640e24bc8 100644
--- a/app/assets/javascripts/discourse/dialects/quote_dialect.js
+++ b/app/assets/javascripts/discourse/dialects/quote_dialect.js
@@ -71,31 +71,13 @@ Discourse.Dialect.replaceBlock({
return ['p', ['aside', params, contents]];
}
- return ['p', ['aside', params,
- ['div', {'class': 'title'},
- ['div', {'class': 'quote-controls'}],
- avatarImg ? ['__RAW', avatarImg] : "",
- username ? I18n.t('user.said', {username: username}) : ""
- ],
- contents
- ]];
+ return ['aside', params,
+ ['div', {'class': 'title'},
+ ['div', {'class': 'quote-controls'}],
+ avatarImg ? ['__RAW', avatarImg] : "",
+ username ? I18n.t('user.said', {username: username}) : ""
+ ],
+ contents
+ ];
}
});
-
-Discourse.Dialect.on("parseNode", function(event) {
- var node = event.node,
- path = event.path;
-
- // Make sure any quotes are followed by a
. The formatting looks weird otherwise.
- if (node[0] === 'aside' && node[1] && node[1]['class'] === 'quote') {
- var parent = path[path.length - 1],
- location = parent.indexOf(node)+1,
- trailing = parent.slice(location);
-
- if (trailing.length) {
- parent.splice(location, 0, ['br']);
- }
- }
-
-});
-
diff --git a/app/models/post_analyzer.rb b/app/models/post_analyzer.rb
index ce6689e601..7c38a8e2c9 100644
--- a/app/models/post_analyzer.rb
+++ b/app/models/post_analyzer.rb
@@ -47,9 +47,9 @@ class PostAnalyzer
# strip quotes and code blocks
cooked_stripped = cooked_document
- cooked_stripped.search("aside.quote").remove
- cooked_stripped.search("pre").remove
- cooked_stripped.search("code").remove
+ cooked_stripped.css("aside.quote").remove
+ cooked_stripped.css("pre").remove
+ cooked_stripped.css("code").remove
results = cooked_stripped.to_html.scan(PrettyText.mention_matcher)
@raw_mentions = results.uniq.map { |un| un.first.downcase.gsub!(/^@/, '') }
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index 7e1e9eacf2..0a078e619f 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -14,15 +14,15 @@ describe PrettyText do
end
it "produces a quote even with new lines in it" do
- PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should match_html "
" + expected + "
", text); }; +var formatQ = function(input, expected, text) { + var cooked = Discourse.Markdown.cook(input, {lookupAvatar: false}); + equal(cooked, expected, text); +}; + test('basic bbcode', function() { format("[b]strong[/b]", "strong", "bolds text"); format("[i]emphasis[/i]", "emphasis", "italics text"); @@ -106,19 +111,19 @@ test("quotes", function() { test("quote formatting", function() { - format("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]", + formatQ("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]", "", "it allows quotes with [] inside"); - format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]", + formatQ("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]", "", "renders quotes properly"); - format("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]\nhello", + formatQ("[quote=\"eviltrout, post:1, topic:1\"]abc[/quote]\nhello", "\n\nhello", + "
\n\nabc
hello
", "handles new lines properly"); }); @@ -126,8 +131,8 @@ test("quote formatting", function() { test("quotes with trailing formatting", function() { var cooked = Discourse.Markdown.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]\nhello\n[/quote]\n*Test*", {lookupAvatar: false}); equal(cooked, - "\n\nTest
", + "\n\nTest
", "it allows trailing formatting"); }); diff --git a/test/javascripts/lib/markdown_test.js b/test/javascripts/lib/markdown_test.js index 863be7f3e0..34d4e9f275 100644 --- a/test/javascripts/lib/markdown_test.js +++ b/test/javascripts/lib/markdown_test.js @@ -161,20 +161,20 @@ test("Quotes", function() { cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n\nthird line[/quote]", { topicId: 2 }, - "", + "", "works with multiple lines"); cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function(name) { return "" + name; }, sanitize: true }, - "1
\n\n\n\n2
", + "1
\n\n\n\n2
", "handles quotes properly"); cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function() { } }, - "1
\n\n\n\n2
", + "1
\n\n\n\n2
", "includes no avatar if none is found"); });