FIX: @mentions within simple quotes

This commit is contained in:
Robin Ward 2013-08-21 16:10:16 -04:00
parent 1004edad1a
commit 30cfa33629
2 changed files with 10 additions and 1 deletions
app/assets/javascripts/discourse/dialects
test/javascripts/components

View file

@ -28,6 +28,7 @@ Discourse.Dialect.on("register", function(event) {
mentionLookup = dialect.options.mentionLookup || Discourse.Mention.lookupCache;
if (block.match(/^ {3}/)) { return; }
if (block.match(/^\>/)) { return; }
var pushIt = function(p) { result.push(p) };
@ -53,6 +54,7 @@ Discourse.Dialect.on("register", function(event) {
if (remaining && remaining.match(/\n/)) {
next.unshift(MD.mk_block(remaining));
return [result];
}
}
@ -60,7 +62,6 @@ Discourse.Dialect.on("register", function(event) {
if (remaining.length) {
this.processInline(remaining).forEach(pushIt);
}
return [result];
}
};

View file

@ -112,6 +112,14 @@ test("Mentions", function() {
"deals correctly with multiple <code> blocks");
cooked("```\na @test\n```", "<p><pre><code class=\"lang-auto\">a @test</code></pre></p>", "should not do mentions within a code block.");
cooked("> foo bar baz @eviltrout",
"<blockquote><p>foo bar baz <span class=\"mention\">@eviltrout</span></p></blockquote>",
"handles mentions in simple quotes");
cooked("> foo bar baz @eviltrout ohmagerd\nlook at this",
"<blockquote><p>foo bar baz <span class=\"mention\">@eviltrout</span></p><p> ohmagerd\nlook at this</p></blockquote>",
"does mentions properly with trailing text within a simple quote");
});
test("Oneboxing", function() {