Created
August 7, 2009 17:16
-
-
Save mretzak/164024 to your computer and use it in GitHub Desktop.
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
# This code will take the raw source text from a tweet and add appropriate links to #hastags, @ replies, and links. The ugly stuff in there is dealing with various formats of html character codes | |
def to_html | |
self.text.gsub("&","&").gsub(/(http:\/\/([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?)/,'<a href="\1" target="_blank" rel="nofollow">\1</a>').gsub(/@(\w+)/,'@<a href="http://twitter.com/\1" target="_blank" rel="nofollow">\1</a>').gsub(/&#/,"~begonia~~").gsub(/#(\w+)/,' #<a href="http://twitter.com/#search?q=%23\1" target="_blank" rel="nofollow">\1</a>').gsub(/~begonia~~/,"&#") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment