Skip to content

Instantly share code, notes, and snippets.

@fd
Created August 29, 2011 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fd/1177983 to your computer and use it in GitHub Desktop.
Save fd/1177983 to your computer and use it in GitHub Desktop.
Glossary Regexp
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