fix username lookup regex for mentions

This commit is contained in:
Jeff Atwood 2013-04-26 14:34:03 -07:00
parent 1375954fbc
commit dd9ea50456
1 changed files with 3 additions and 3 deletions

View File

@ -142,13 +142,13 @@ Discourse.Markdown = {
converter.hooks.chain("postConversion", function(text) {
if (!text) return "";
// don't to mention voodoo in pres
// don't do @username mentions inside <pre> blocks
text = text.replace(/<pre>([\s\S]*@[\s\S]*)<\/pre>/gi, function(wholeMatch, inner) {
return "<pre>" + (inner.replace(/@/g, '&#64;')) + "</pre>";
});
// Add @mentions of names
text = text.replace(/([\s\t>,:'|";\]])(@[A-Za-z0-9_-|\.]*[A-Za-z0-9_-|]+)(?=[\s\t<\!:|;',"\?\.])/g, function(x, pre, name) {
// add @username mentions, if valid; must be bounded on left and right by non-word characters
text = text.replace(/(\W)(@[A-Za-z0-9][A-Za-z0-9_]{2,14})(?=\W)/g, function(x, pre, name) {
if (mentionLookup(name.substr(1))) {
return pre + "<a href='" + Discourse.getURL("/users/") + (name.substr(1).toLowerCase()) + "' class='mention'>" + name + "</a>";
} else {