(text: string, end: number, floor: number)
| 496 | |
| 497 | /** moves `end` back to the end of a word, but never before `floor` */ |
| 498 | const wordEnd = (text: string, end: number, floor: number) => { |
| 499 | if (end >= text.length) return text.length |
| 500 | const space = text.slice(floor, end + 1).search(/\s\S*$/) |
| 501 | return space === -1 ? end : floor + space |
| 502 | } |
| 503 | |
| 504 | /** the words around the first matched term, with matches marked */ |
| 505 | const excerpt = (text: string, result: SearchResult): ReactNode => { |