Beitragsansicht

This commit is contained in:
Simon Martens
2025-02-27 21:05:34 +01:00
parent d2e7f91c92
commit caaf86f90d
14 changed files with 692 additions and 175 deletions

View File

@@ -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
}