mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: Don't onebox @mentions
This commit is contained in:
parent
1ef9354e21
commit
20e8a8a38a
3 changed files with 12 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
To extend the dialect, you can register a handler, and you will receive an `event` object
|
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
|
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":
|
"EVIL TROUT IS AWESOME":
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
|
@ -49,6 +49,9 @@ Discourse.Dialect.on("parseNode", function(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't onebox mentions
|
||||||
|
if (node[1]['class'] === 'mention') { return; }
|
||||||
|
|
||||||
// Don't onebox links within a list
|
// Don't onebox links within a list
|
||||||
for (var i=0; i<path.length; i++) {
|
for (var i=0; i<path.length; i++) {
|
||||||
if (path[i][0] === 'li') { return; }
|
if (path[i][0] === 'li') { return; }
|
||||||
|
|
|
@ -116,7 +116,10 @@ test("Quotes", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Mentions", 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>",
|
"<p>Hello <a class=\"mention\" href=\"/users/sam\">@sam</a></p>",
|
||||||
"translates mentions to links");
|
"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>",
|
"<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.");
|
"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() {
|
test("Oneboxing", function() {
|
||||||
|
|
Loading…
Reference in a new issue