summaryrefslogtreecommitdiffstats
path: root/modules/markdown/markdown.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-07-16 00:36:39 +0800
committerUnknwon <u@gogs.io>2016-07-16 00:36:39 +0800
commitf1b8d52eb3ac230ed5a275f4a844ddb0cf48041e (patch)
tree51dda05a9fb7a985a4e91f3e1708ffddf3fee19c /modules/markdown/markdown.go
parent7ca5f8f119593023809e6130db75154597c52426 (diff)
downloadgitea-f1b8d52eb3ac230ed5a275f4a844ddb0cf48041e.tar.gz
gitea-f1b8d52eb3ac230ed5a275f4a844ddb0cf48041e.zip
#2854 fix no mail notification when issue is closed/reopened
Diffstat (limited to 'modules/markdown/markdown.go')
-rw-r--r--modules/markdown/markdown.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go
index 99a4323d99..d49c14d1f9 100644
--- a/modules/markdown/markdown.go
+++ b/modules/markdown/markdown.go
@@ -93,6 +93,16 @@ var (
Sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{40}\b`)
)
+// FindAllMentions matches mention patterns in given content
+// and returns a list of found user names without @ prefix.
+func FindAllMentions(content string) []string {
+ mentions := MentionPattern.FindAllString(content, -1)
+ for i := range mentions {
+ mentions[i] = strings.TrimSpace(mentions[i])[1:] // Strip @ character
+ }
+ return mentions
+}
+
// Renderer is a extended version of underlying render object.
type Renderer struct {
blackfriday.Renderer
@@ -202,6 +212,9 @@ func (r *Renderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byt
// cutoutVerbosePrefix cutouts URL prefix including sub-path to
// return a clean unified string of request URL path.
func cutoutVerbosePrefix(prefix string) string {
+ if len(prefix) == 0 || prefix[0] != '/' {
+ return prefix
+ }
count := 0
for i := 0; i < len(prefix); i++ {
if prefix[i] == '/' {