1.0.2 ā€¢ Published 8 years ago

text-highlighter v1.0.2

Weekly downloads
2
License
MIT
Repository
-
Last release
8 years ago

text-highlighter

Highlight text in DOM.

npm

Installation

$ npm install text-highlighter --save

Usage

<div id="container">
We šŸ’“ TypeScript!
</div>

<script src="lib/text-highlighter.js"></script>
<script>
  var textHighlighter = new TextHighlighter(document.getElementById('container'));
  // apply highlight
  textHighlighter.highlight('typescript');

  // remove highlight
  textHighlighter.dehighlight();
</script>

Support Zenkaku & Hankaku

before

<div id="container">
We šŸ’“ ļ¼“ļ½™ļ½ļ½…ļ¼³ļ½ƒļ½’ļ½‰ļ½ļ½”!
</div>

<script>
  ...
  // apply highlight
  textHighlighter.highlight('typescript');
</script>

after

<div id="container">
We šŸ’“ <mark>ļ¼“ļ½™ļ½ļ½…ļ¼³ļ½ƒļ½’ļ½‰ļ½ļ½”</mark>!
</div>

Thanks

License

MIT