From 20e8a8a38a50858a60c7f516aedef1758fefe580 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Sat, 24 Aug 2013 15:00:18 -0400 Subject: [PATCH] FIX: Don't onebox @mentions --- app/assets/javascripts/discourse/dialects/dialect.js | 2 +- .../javascripts/discourse/dialects/onebox_dialect.js | 3 +++ test/javascripts/components/markdown_test.js | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index 3fe570c2d25..9a5b6ce976e 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -5,7 +5,7 @@ To extend the dialect, you can register a handler, and you will receive an `event` object with a handle to the markdown `Dialect` from Markdown.js that we are defining. Here's - a sample dialect that replaces all occurances of "evil trout" with a link that says + a sample dialect that replaces all occurrences of "evil trout" with a link that says "EVIL TROUT IS AWESOME": ```javascript diff --git a/app/assets/javascripts/discourse/dialects/onebox_dialect.js b/app/assets/javascripts/discourse/dialects/onebox_dialect.js index f99e9583d08..4c4ebd38986 100644 --- a/app/assets/javascripts/discourse/dialects/onebox_dialect.js +++ b/app/assets/javascripts/discourse/dialects/onebox_dialect.js @@ -49,6 +49,9 @@ Discourse.Dialect.on("parseNode", function(event) { return; } + // We don't onebox mentions + if (node[1]['class'] === 'mention') { return; } + // Don't onebox links within a list for (var i=0; iHello @sam

", "translates mentions to links"); @@ -162,6 +165,10 @@ test("Mentions", function() { "
  1. this is a list

  2. this is an @eviltrout mention

", "it mentions properly in a list."); + cookedOptions("@eviltrout", alwaysTrue, + "

@eviltrout

", + "it doesn't onebox mentions"); + }); test("Oneboxing", function() {