1.0.0 • Published 5 years ago

keylight v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

To highlight some key content with color

demo

  • demo1 demo1
  • demo2 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'