mirror of
1
Fork 0
Fixes #921 and makes the Mention regexp be in line with the others
This commit is contained in:
Peter Smit 2015-02-09 12:56:46 +02:00
parent 6ed96b7a20
commit 5cd887dba5
1 changed files with 3 additions and 2 deletions

View File

@ -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(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[2:], m)), -1)
[]byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[1:], m)), -1)
}
}