MCPcopy Create free account
hub / github.com/gogs/gogs / RenderIssueIndexPattern

Function RenderIssueIndexPattern

internal/markup/markup.go:94–123  ·  view source on GitHub ↗

RenderIssueIndexPattern renders issue indexes to corresponding links.

(rawBytes []byte, urlPrefix string, metas map[string]string)

Source from the content-addressed store, hash-verified

92
93// RenderIssueIndexPattern renders issue indexes to corresponding links.
94func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string]string) []byte {
95 urlPrefix = cutoutVerbosePrefix(urlPrefix)
96
97 pattern := IssueNumericPattern
98 if metas["style"] == IssueNameStyleAlphanumeric {
99 pattern = IssueAlphanumericPattern
100 }
101
102 ms := pattern.FindAll(rawBytes, -1)
103 for _, m := range ms {
104 if m[0] == ' ' || m[0] == '(' || m[0] == '[' {
105 // ignore leading space, opening parentheses, or opening square brackets
106 m = m[1:]
107 }
108 var link string
109 if metas == nil || metas["format"] == "" {
110 link = fmt.Sprintf(`<a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)
111 } else {
112 // Support for external issue tracker
113 if metas["style"] == IssueNameStyleAlphanumeric {
114 metas["index"] = string(m)
115 } else {
116 metas["index"] = string(m[1:])
117 }
118 link = fmt.Sprintf(`<a href="%s">%s</a>`, expand(metas["format"], metas), m)
119 }
120 rawBytes = bytes.Replace(rawBytes, m, []byte(link), 1)
121 }
122 return rawBytes
123}
124
125// Note: this section is for purpose of increase performance and
126// reduce memory allocation at runtime since they are constant literals.

Callers 3

RenderCommitMessageFunction · 0.92
RenderSpecialLinkFunction · 0.85

Calls 4

cutoutVerbosePrefixFunction · 0.85
stringFunction · 0.85
expandFunction · 0.85
FindAllMethod · 0.80

Tested by 1