Skip to content

Instantly share code, notes, and snippets.

@jlapier
Created March 2, 2010 04:56
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 jlapier/319151 to your computer and use it in GitHub Desktop.
Save jlapier/319151 to your computer and use it in GitHub Desktop.
# get rid of weird characters from pasting from Word and stuff
def cleanup(text)
if text
text.
gsub(/&/, '&').
gsub(/&[lr]?quot;/, '"').
gsub(/'/, "'").
gsub(/'/, "'").
gsub(/>/, '>').
gsub(/&lt;/, '<').
gsub(/&nbsp;/, ' ').
gsub(%r{</?[^>]+>}, '').
gsub(/\*\s*\*/, '**').
gsub(/\342\200\235/, '"').
gsub(/\342\200\234/, '"').
gsub(/\342\200\231/, "'").
gsub(/\342\200\223/, " -- ").
gsub(/\342\200\224/, " -- ").
gsub(/\303\242/, "a").
gsub(/\303\251/, "e").
gsub(%r{/+\s*$}, '')
else
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment