I wanted to know if there\'s any way I could output HTML after extracting contents()
and performing a replace on all of the text-nodes in it.
jsFiddle:
Your problem is that you're inserting the HTML into a text node (and it's therefore being treated as text). Instead of replacing _link_
with Google
, you'd want to take the text node, remove the text from _link_
onward, append an HTML node (that contains the anchor) and put all of text after _link_
into a new text node following that.