Fix team links in HTML rendering (#9127)
* Fix team links in HTML rendering * Fix check and lint
This commit is contained in:
parent
7523314ef8
commit
f25fd5c8eb
3 changed files with 46 additions and 17 deletions
|
@ -432,14 +432,20 @@ func replaceContentList(node *html.Node, i, j int, newNodes []*html.Node) {
|
|||
}
|
||||
}
|
||||
|
||||
func mentionProcessor(_ *postProcessCtx, node *html.Node) {
|
||||
func mentionProcessor(ctx *postProcessCtx, node *html.Node) {
|
||||
// We replace only the first mention; other mentions will be addressed later
|
||||
found, loc := references.FindFirstMentionBytes([]byte(node.Data))
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
mention := node.Data[loc.Start:loc.End]
|
||||
replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention"))
|
||||
var teams string
|
||||
teams, ok := ctx.metas["teams"]
|
||||
if ok && strings.Contains(teams, ","+strings.ToLower(mention[1:])+",") {
|
||||
replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, "org", ctx.metas["org"], "teams", mention[1:]), mention, "mention"))
|
||||
} else {
|
||||
replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention"))
|
||||
}
|
||||
}
|
||||
|
||||
func shortLinkProcessor(ctx *postProcessCtx, node *html.Node) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue