keylight
v1.0.0
Published
Highlight key content
Downloads
7
Readme
To highlight some key content with color
demo
- demo1
- demo2
usage
// install
yarn add keylight
// import
import keylight from 'keylight'
// use
const kl = new keylight('#f701bc')
const content = "hello world"
const key = "hello"
const hightContent = kl.match(content, key)
// => '<span style="color:#f701bc;">hello</span> world'
// change color
kl.color = '#ababab'
const hightContent = kl.match(content, key)
// => '<span style="color:#ababab;">hello</span> world'
// additional operating
const upperCase = val => val.toUpperCase()
const hightContent = kl.match(content, key, uppercase)
// => '<span style="color:#ababab;">HELLO</span> world'