jQuery Tweetify

$(element).tweetify();

by lovromar

HTML

<div id="test">Lorem ipsum dolor sit et @gabromanato ibat forte sicut est mos sed http://blog.gabrieleromanato.com/ etiam atque #domus.</p>

CSS

#test {
    margin: 1em;
    line-height: 1.4;
}

JavaScript

(function($) {
    $.fn.tweetify = function() {
        var that = this;
        var html = that.html();
        that.each(function() {
            $(that).html(
            html.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1">$1</a>').replace(/(^|\s)@(\w+)/g, '$1<a href="http://twitter.com/@$2">@$2</a>').
            replace(/(^|\s)#(\w+)/g, '$1<a href="http://twitter.com/search/#$2">#$2</a>'));
        });
        return this;
    }
})(jQuery);



$('#test').tweetify();