Browse Source

Merge pull request #826 from deringer/dev

Fix user mention bug when parsing markdown documents
pull/915/head
无闻 10 years ago
parent
commit
ddddad9792
  1. 4
      modules/base/markdown.go
  2. 3
      public/ng/css/gogs.css

4
modules/base/markdown.go

@ -106,7 +106,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte,
} }
var ( var (
MentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`) MentionPattern = regexp.MustCompile(`(\s@)[0-9a-zA-Z_]{1,}`)
commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[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-]*)?`) issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`) issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`)
@ -129,7 +129,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte {
ms := MentionPattern.FindAll(line, -1) ms := MentionPattern.FindAll(line, -1)
for _, m := range ms { for _, m := range ms {
line = bytes.Replace(line, m, line = bytes.Replace(line, m,
[]byte(fmt.Sprintf(`<a href="%s/user/%s">%s</a>`, setting.AppSubUrl, m[1:], m)), -1) []byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[2:], m)), -1)
} }
} }

3
public/ng/css/gogs.css

@ -448,6 +448,9 @@ img.avatar-100 {
margin: 15px 0; margin: 15px 0;
border-bottom: 2px solid #EEE; border-bottom: 2px solid #EEE;
} }
.markdown p {
margin: 20px 0;
}
.markdown blockquote:last-child, .markdown blockquote:last-child,
.markdown ul:last-child, .markdown ul:last-child,
.markdown ol:last-child, .markdown ol:last-child,

Loading…
Cancel
Save