From 5cd887dba5dea90470435bfa338b70c5c036019e Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Mon, 9 Feb 2015 12:56:46 +0200 Subject: [PATCH] Fixes #921 Fixes #921 and makes the Mention regexp be in line with the others --- modules/base/markdown.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index b5f397dce0..4a7adc8a48 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -106,7 +106,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, } var ( - MentionPattern = regexp.MustCompile(`((^|\s)@)[0-9a-zA-Z_]{1,}`) + MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_]+`) commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`) issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`) issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`) @@ -128,8 +128,9 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { if !inCodeBlock && !bytes.HasPrefix(line, tab) { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { + m = bytes.TrimSpace(m) line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[2:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[1:], m)), -1) } }