Guest User

Untitled

a guest
May 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def highlight_for_word(text, words, color)
  2. return text if (text =~ /#{words.join('|')}/i).nil?
  3. color = 'yellow'
  4. replacement = '</w:t></w:r><w:r><w:rPr><w:highlight w:val="' + color + '"/></w:rPr><w:t>\1</w:t></w:r><w:r><w:t>'
  5. words.each do |word|
  6. raise text.gsub(/(#{word})/, replacement)
  7. end
  8. text
  9. end
Add Comment
Please, Sign In to add comment