all repos — searchix @ 896d844cac976afd0ee8aa73dd2fb28e15e7ac79

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
}