all repos — searchix @ ff1e9539fca1f011cfd52d0309a373f211c3fd10

Search engine for NixOS, nix-darwin, home-manager and NUR users

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(`^.*?\.[[:space:]]`)

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

	return text
}