Created
March 2, 2010 04:56
-
-
Save jlapier/319151 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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(/</, '<'). | |
gsub(/ /, ' '). | |
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