Highlight portions of text given text, a filter and an optional className.
$ npm install highlightify --save
First, install it via NPM and save it to your project:
$ npm install highlightify --save
Import it where you need it:
import Highlightify from 'highlightify';
or if you are using < ES2015,
var Highlightify= require('highlightify');
and then call it with text
, filter
, and/or optional tagName
or className
options:
Highlightify({
text: 'some text to match against', // required
filter: 'ext', // required
tagName: 'span', // optional. default: 'mark'
className: 'is-highlighted' // optional. default: 'highlightify-is-match'
});
// => 'some t<span class="is-highlighted">ext</span> to match against'
Simply include the dist
script on the page to gain access to it. There are development & production builds in the dist
folder.
<!DOCTYPE html>
<html>
<head></head>
<body>
<script src="path/to/highlightify.js"></script>
</body>
</html>
- Check out the issues
- Fork this repository
- Clone your fork
- Check out a feature branch (
$ git checkout -b my-feature
) - Make your changes and push your branch to your GitHub repo
- Create a pull request from your branch to this repo's master
- When all is merged, pull down the upstream changes to your master