Created
July 17, 2009 04:50
-
-
Save atnan/148891 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
var ify = function() { | |
return { | |
"link": function(t) { | |
return t.replace(/(^|\s+)(https*\:\/\/\S+)/g, function(m, m1, link) { | |
return m1.concat('<a href="', link, '">', link.substr(0, 24), 25 < link.length ? '...' : '', '</a>'); | |
}); | |
}, | |
"at": function(t) { | |
return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, ‘$1@<a href=”http://twitter.com/$2″>$2</a>’); | |
}, | |
“hash”: function(t) { | |
return t.replace(/(^|\s+)\#([a-zA-Z0-9_]+)/g, ‘$1#<a href=”http://search.twitter.com/search?q=%23$2″>$2</a>’); | |
}, | |
clean: function(tweet) { | |
return this.hash(this.at(this.link(tweet))); | |
} | |
}; | |
}(); |
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
var ify = function() { | |
return { | |
"link": function(t) { | |
return t.replace(/(^|\s+)(https*\:\/\/\S+[^\.\s+])/g, function(m, m1, link) { | |
return m1 + '<a href=' + link + '>' + ((link.length > 25) ? link.substr(0, 24) + '...' : link) + '</a>'; | |
}); | |
}, | |
"at": function(t) { | |
return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, function(m, m1, m2) { | |
return m1 + '@<a href="http://twitter.com/' + m2 + '">' + m2 + '</a>'; | |
}); | |
}, | |
"hash": function(t) { | |
return t.replace(/(^|\s+)\#([a-zA-Z0-9_]+)/g, function(m, m1, m2) { | |
return m1 + '#<a href="http://search.twitter.com/search?q=%23' + m2 + '">' + m2 + '</a>'; | |
}); | |
}, | |
"clean": function(tweet) { | |
return this.hash(this.at(this.link(tweet))); | |
} | |
}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment