Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def highlight_for_word(text, words, color)
- return text if (text =~ /#{words.join('|')}/i).nil?
- color = 'yellow'
- 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>'
- words.each do |word|
- raise text.gsub(/(#{word})/, replacement)
- end
- text
- end
Add Comment
Please, Sign In to add comment