mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Beitragsansicht
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
var linksexp = regexp.MustCompile(`INr\s*([0-9]+)(?:\s*[-,;]\s*[0-9]*)*\s*(?:,|;)?\s*(?:obj|Obj)?\s*[0-9]*(?:\s*[-,;]\s*[0-9]*)*`)
|
||||
|
||||
func Safe(s string) template.HTML {
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
@@ -39,3 +43,15 @@ func First(s string) string {
|
||||
|
||||
return string(r[0])
|
||||
}
|
||||
|
||||
func LinksAnnotation(s string) string {
|
||||
annotation := linksexp.ReplaceAllStringFunc(s, func(match string) string {
|
||||
submatches := linksexp.FindStringSubmatch(match)
|
||||
if len(submatches) > 1 {
|
||||
return fmt.Sprintf(`<a href="#%s" class="link-default oldstyle-nums">%s</a>`, submatches[1], match)
|
||||
}
|
||||
return match
|
||||
})
|
||||
|
||||
return annotation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user