JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div>
<a href="http://stackoverflow.com">Already a link</a>
<ul>
<li>
<span>
http://apple.com
</span>
</li>
</ul>
content
http://microsoft.com
more content
http://yahoo.com
<span>more conten http://google.com</span>
</div>
JavaScript
var re = /(http:\/\/[^ ]+)/g;
function createLinks( els ) {
$(els).contents().each( function() {
if( this.nodeType === 1 && this.nodeName !== 'script' ) {
createLinks( this );
} else if( this.nodeType === 3 && this.data.match( re ) ) {
var markup = this.data.replace( re, '<a href="$1">$1</a>' );
$( this ).replaceWith( markup );
}
});
}
createLinks( document.body );