highlight-matches-utils
Utility functions to mark and highlight character matches in text
See an online example in CodeSandbox on how it can be used.
API
For more in-depth examples, check the test file.
For more in-depth documentation, check the TypeScript definition file.
highlightChars
Calls the given functions on matching and non-matching characters of the given text. Useful when you want to highlight matching characters in a UI.
Example:
// => ['How ', '(are)', ' you?'] // => ['How ', <mark>are</mark>, ' you?'] // =>// [// "[90mHow [39m",// "[0mare[0m",// "[90m you?[39m",// ]// (useful for highlighting CLI output)
highlightMatches
Calls the given functions on matching and non-matching characters of the given text. Useful when you want to highlight matching characters in a UI.
NOTE: You can get the
matches
by callingfuzzaldrin-plus
's.match()
function.
splitMatches
Splits the given text in separate chunks grouping together all the characters that are matches and not matches.
NOTE: You can get the
matches
by callingfuzzaldrin-plus
's.match()
function.