1.0.2 • Published 3 years ago

matched-highlight v1.0.2

Weekly downloads
75
License
ISC
Repository
github
Last release
3 years ago

matched-highlight help us match text to raw html string.

Get started

npm i matched-highlight

Demo

const highlight = require("matched-highlight")

// default: highlight(query, text, opts = { tag: "strong", consecutive: false })

highlight("thin", "this is a thin text on input.")
// => '<strong>thi</strong>s is a thi<strong>n</strong> text on input.'

highlight("thin", "this is a thin text on input.", { consecutive: true })
// => 'this is a <strong>thin</strong> text on input.'

highlight("thin", "this is a thin text on input.", { tag: "b", consecutive: true })
// => 'this is a <b>thin</b> text on input.'