RENDER HTML AS TEXT - SHORTCODE RENDERING - BIZAMAJIG USAGE

by bizamajig

HTML

<!--
Well, one way would be to use jQuery. the jQuery .text() method will encode special characters. And the original un-encoded text will remain if you view source.

<div id="text">
    <a href="">This is an anchor</a>
</div>

<script>
    var t = $('#text'); t.html(t.text());
</script>
shareimprove this answer
answered Jul 26 '12 at 16:49

That will show a serialisation of the DOM created from the HTML, not the original HTML. It will also show a flash of rendered content. – Quentin Jul 26 '12 at 16:51 
  	 	
Though in most cases those would be the same. And there are ways around the flashing, 	 	
of course using, display:none;
-->

<p>
Without noparse: <a href="http://example.com">Link</a>
</p>
<p>
</p>
<p>
With noparse: <noparse><a href="http://example.com">Link</a></noparse>
</p>

JavaScript

//finds noparse and changes it
function findNoParse(){
	$('noparse').each(function(){
		if($(this).attr('tagchecked') != 'true'){ // checks if already changed tag
			$(this).text($(this).html()); // makes the html into plaintext
			$(this).attr('tagchecked', 'true'); // says that tag has been checked
		}
	});
}

//make sure to load when page is loaded
$(document).ready(function(){
    findNoParse();
    setInterval(findNoParse, 100); //constantly check for new tag, just in case a new element is put in.
});