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

Function RenderSha1CurrentPattern

internal/markup/markup.go:148–156  ·  view source on GitHub ↗

RenderSha1CurrentPattern renders SHA1 strings to corresponding links that assumes in the same repository.

(rawBytes []byte, urlPrefix string)

Source from the content-addressed store, hash-verified

146
147// RenderSha1CurrentPattern renders SHA1 strings to corresponding links that assumes in the same repository.
148func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
149 return []byte(Sha1CurrentPattern.ReplaceAllStringFunc(string(rawBytes), func(m string) string {
150 if com.StrTo(m).MustInt() > 0 {
151 return m
152 }
153
154 return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, tool.ShortSHA1(m))
155 }))
156}
157
158// RenderSpecialLink renders mentions, indexes and SHA1 strings to corresponding links.
159func RenderSpecialLink(rawBytes []byte, urlPrefix string, metas map[string]string) []byte {

Callers 2

RenderSpecialLinkFunction · 0.85

Calls 3

ShortSHA1Function · 0.92
stringFunction · 0.85
ReplaceAllStringFuncMethod · 0.80

Tested by 1