combine a common fmt string
This commit is contained in:
parent
7111e8a93d
commit
3b48371b49
7
fun.go
7
fun.go
|
@ -454,18 +454,17 @@ func fullname(name string, userid int64) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mentionize(s string) string {
|
func mentionize(s string) string {
|
||||||
|
fill := `<span class="h-card"><a class="u-url mention" href="%s">%s</a></span>`
|
||||||
s = re_mentions.ReplaceAllStringFunc(s, func(m string) string {
|
s = re_mentions.ReplaceAllStringFunc(s, func(m string) string {
|
||||||
where := gofish(m)
|
where := gofish(m)
|
||||||
if where == "" {
|
if where == "" {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
who := m[0 : 1+strings.IndexByte(m[1:], '@')]
|
who := m[0 : 1+strings.IndexByte(m[1:], '@')]
|
||||||
return fmt.Sprintf(`<span class="h-card"><a class="u-url mention" href="%s">%s</a></span>`,
|
return fmt.Sprintf(fill, html.EscapeString(where), html.EscapeString(who))
|
||||||
html.EscapeString(where), html.EscapeString(who))
|
|
||||||
})
|
})
|
||||||
s = re_urltions.ReplaceAllStringFunc(s, func(m string) string {
|
s = re_urltions.ReplaceAllStringFunc(s, func(m string) string {
|
||||||
return fmt.Sprintf(`<span class="h-card"><a class="u-url mention" href="%s">%s</a></span>`,
|
return fmt.Sprintf(fill, html.EscapeString(m[1:]), html.EscapeString(m))
|
||||||
html.EscapeString(m[1:]), html.EscapeString(m))
|
|
||||||
})
|
})
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue