Created
August 29, 2011 08:09
-
-
Save fd/1177983 to your computer and use it in GitHub Desktop.
Glossary Regexp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description = file.description.clone | |
@glossary.each do |w| | |
terms = w.name.split(',') | |
terms.each do |term| | |
term = Regexp.escape(term.strip).gsub('\ ', '\s+') | |
description.gsub!(/(\b#{term}\b)/i, "<acronym rel=\"#{w.id}\">\\1</acronym>") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment