JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<div class="a-entry">
This is an example text with an example <img alt="example" src="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" /> Going to <a href="http://example.com">example.com</a></div>
JavaScript
function getArticleContent() {
var toPromote = 'example';
$(".a-entry").contents().filter(function() {
return this.nodeType == 3;
}).each(function() {
if(this.nodeValue.indexOf(toPromote) > -1)
$(this).replaceWith(this.nodeValue.replace(new RegExp(toPromote, "g"), function(m) {
return '<a href="/tags/'+m+'">'+m+'</a>'
}));
});
}
$(document).ready(function() {
getArticleContent();
});