document.write('<link rel="stylesheet" href="http://gist.github.com/stylesheets/gist/embed.css"/>')





document.write('<div id=\"gist-135601\" class=\"gist\">\n  \n  \n    \n            \n\n      <div class=\"gist-file\">\n        <div class=\"gist-data gist-syntax\">\n          \n          \n          \n            <div class=\"gist-highlight\"><pre><div class=\"line\" id=\"LC1\">class String<\/div><div class=\"line\" id=\"LC2\">&nbsp;&nbsp;def emphasize substrings<\/div><div class=\"line\" id=\"LC3\">&nbsp;&nbsp;&nbsp;&nbsp;cleaned = [substrings].flatten.compact.uniq.map(&amp;:strip).reject(&amp;:empty?)<\/div><div class=\"line\" id=\"LC4\">&nbsp;&nbsp;&nbsp;&nbsp;return self.clone if cleaned.empty?<\/div><div class=\"line\" id=\"LC5\">&nbsp;&nbsp;&nbsp;&nbsp;returning to_s do |em|<\/div><div class=\"line\" id=\"LC6\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cleaned.inject em do |s, sub|<\/div><div class=\"line\" id=\"LC7\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.gsub!(%r/(#{sub})/i, \'&lt;em&gt;\\1&lt;/em&gt;\') || s<\/div><div class=\"line\" id=\"LC8\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<\/div><div class=\"line\" id=\"LC9\">&nbsp;&nbsp;&nbsp;&nbsp;end<\/div><div class=\"line\" id=\"LC10\">&nbsp;&nbsp;end<\/div><div class=\"line\" id=\"LC11\">end<\/div><div class=\"line\" id=\"LC12\">&nbsp;<\/div><\/pre><\/div>\n        \n        <\/div>\n\n        <div class=\"gist-meta\">\n          <a href=\"http://gist.github.com/raw/135601/ccc2c1d0e6683a147bc29698d8852e9bdb3d6742/String%23emphasize\" style=\"float:right;\">view raw<\/a>\n          <a href=\"http://gist.github.com/135601#file_string#emphasize\" style=\"float:right;margin-right:10px;color:#666\">String#emphasize<\/a>\n          <a href=\"http://gist.github.com/135601\">This Gist<\/a> brought to you by <a href=\"http://github.com\">GitHub<\/a>.\n        <\/div>\n      <\/div>\n    \n  \n<\/div>\n')
