npm.io
1.0.0 • Published 7 years ago

keylight

Licence
MIT
Version
1.0.0
Deps
0
Size
126 kB
Vulns
0
Weekly
0
Stars
2

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'

Keywords