about summary refs log tree commit diff stats
path: root/internal/components/markdown.go
blob: a26fe3d51d4cdd5f87ff21940f74fd6ed112b015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package components

import (
	"regexp"
)

var firstSentenceRegexp = regexp.MustCompile(`^.+?(\.[[:space:]]|:\n)`)

func firstSentence[T ~string](text T) T {
	if fs := firstSentenceRegexp.FindString(string(text)); fs != "" {
		return T(fs)
	}

	return text
}