Guest User

Untitled

a guest
Jul 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. highlightText = (node, words) => {
  2. const fileText = node;
  3. const highlighted_text = words.reduce((text, word) => {
  4. return text.replace( new RegExp(word, 'g'), `<a id="${this.guidGenerator()}" class="highlighted">${word}</a>` );
  5. }, fileText);
  6. node = highlighted_text;
  7. console.log('node: ', node);
  8. // console.log(words);
  9. // this.highlightText(document.querySelector('#text_snippet'), words);
  10. }
Add Comment
Please, Sign In to add comment