Skip to content

isoden/text-highlighter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Highlight text in DOM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published