internal/components/markdown.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package components
import (
"regexp"
)
var firstSentenceRegexp = regexp.MustCompile(`^((?s).+?)(?:\.[[:space:]]*[[:upper:]]|$)`)
func firstSentence[T ~string](text T) T {
if fs := firstSentenceRegexp.FindStringSubmatch(string(text)); len(fs) > 0 && fs[1] != "" {
return T(fs[1])
}
return text
}
|