Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 1.05 KB

README.md

File metadata and controls

61 lines (42 loc) · 1.05 KB

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 💓 TypeScript!
</div>

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

after

<div id="container">
We 💓 <mark>TypeScript</mark>!
</div>

Thanks

License

MIT