all repos — searchix @ 93b800b4862d5c7e0e621647d78b79416a9f3101

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:]]|:\n)`)

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

	return text
}