diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-07 12:56:40 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-07 12:56:40 -0400 |
commit | 9ea9818d3255e5b08293205e278240dece36687d (patch) | |
tree | 51c6a65586843082f451ee1e93082fec5784ccd2 /modules/base/markdown.go | |
parent | 05fb34eacdbec59fb8bcdf96c82c0855e6ec78d2 (diff) | |
download | gitea-9ea9818d3255e5b08293205e278240dece36687d.tar.gz gitea-9ea9818d3255e5b08293205e278240dece36687d.zip |
Fix issue with log in with GitHub but need more error handle after
Diffstat (limited to 'modules/base/markdown.go')
-rw-r--r-- | modules/base/markdown.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go index f0992d04df..ce1e2f5bec 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -90,21 +90,21 @@ func (options *CustomRender) Link(out *bytes.Buffer, link []byte, title []byte, } var ( - mentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`) + MentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`) 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(`(\s|^)#[0-9]+`) + issueIndexPattern = regexp.MustCompile(`#[0-9]+`) ) func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { - ms := mentionPattern.FindAll(rawBytes, -1) + ms := MentionPattern.FindAll(rawBytes, -1) for _, m := range ms { rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf(`<a href="/user/%s">%s</a>`, m[1:], m)), -1) } ms = commitPattern.FindAll(rawBytes, -1) for _, m := range ms { - m = bytes.TrimPrefix(m, []byte(" ")) + m = bytes.TrimSpace(m) i := strings.Index(string(m), "commit/") j := strings.Index(string(m), "#") if j == -1 { @@ -115,7 +115,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { } ms = issueFullPattern.FindAll(rawBytes, -1) for _, m := range ms { - m = bytes.TrimPrefix(m, []byte(" ")) + m = bytes.TrimSpace(m) i := strings.Index(string(m), "issues/") j := strings.Index(string(m), "#") if j == -1 { @@ -126,9 +126,8 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { } ms = issueIndexPattern.FindAll(rawBytes, -1) for _, m := range ms { - m = bytes.TrimPrefix(m, []byte(" ")) rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf( - ` <a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)), -1) + `<a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)), -1) } return rawBytes } |