FIX: Don't onebox @mentions

This commit is contained in:
Robin Ward 2013-08-24 15:00:18 -04:00
parent 1ef9354e21
commit 20e8a8a38a
3 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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; i<path.length; i++) {
if (path[i][0] === 'li') { return; }

View file

@ -116,7 +116,10 @@ test("Quotes", function() {
});
test("Mentions", function() {
cookedOptions("Hello @sam", { mentionLookup: (function() { return true; }) },
var alwaysTrue = { mentionLookup: (function() { return true; }) };
cookedOptions("Hello @sam", alwaysTrue,
"<p>Hello <a class=\"mention\" href=\"/users/sam\">@sam</a></p>",
"translates mentions to links");
@ -162,6 +165,10 @@ test("Mentions", function() {
"<ol><li><p>this is a list</p></li><li><p>this is an <span class=\"mention\">@eviltrout</span> mention </p></li></ol>",
"it mentions properly in a list.");
cookedOptions("@eviltrout", alwaysTrue,
"<p><a class=\"mention\" href=\"/users/eviltrout\">@eviltrout</a></p>",
"it doesn't onebox mentions");
});
test("Oneboxing", function() {