about summary refs log tree commit diff stats
path: root/internal/components/markdown.go
blob: 405ab525b62c3cf289b3f1bd8c027c29a8657d8b (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:]]`)

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

	return text
}