package lipglossimport ()// StyleRanges applying styling to ranges in a string. Existing styles will be// taken into account. Ranges should not overlap.func ( string, ...Range) string {iflen() == 0 {return }varstrings.Builder := 0 := ansi.Strip()// Use Truncate and TruncateLeft to style match.MatchedIndexes without // losing the original option style:for , := range {// Add the text before this matchif .Start > { .WriteString(ansi.Cut(, , .Start)) }// Add the matched range with its highlight .WriteString(.Style.Render(ansi.Cut(, .Start, .End))) = .End }// Add any remaining text after the last match .WriteString(ansi.TruncateLeft(, , ""))return .String()}// NewRange returns a range and style that can be used with [StyleRanges].func (, int, Style) Range {returnRange{, , }}// Range is a range of text and associated styling to be used with// [StyleRanges].typeRangestruct {Start, EndintStyleStyle}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)