This works quite well for preventing the html tags from rendering but when i use with prettify, it displays as a massive block of code without styles. Im sure there is something conflicting, but rather, are there any alternatives that are more popular for the fix im trying to attempt?
jsfiddle: http://jsfiddle.net/john_motyl/2QFnB/ (swap the id to see what im talking about)
I'm not seeing the issue you are describing, but I would think if you escaped the HTML before running prettyPrint your problems should go away.
Just to make sure you know that all syntax hilighting scripts add something like a span around bits of the code to colorize it, so it sounds like those elements are being converted by the escapeHTML script above and messing up the look.
@mottie, your absolutely correct. I was calling prettyprint() before trying to escape the html entities. Thanks for pointing that out, i totally overlooked that. Now i call that function inside my if statement and it works perfect. Thanks
prettyprintaka prettify to display code. Rather than having to convert all of my < and > entities i am using this function:This works quite well for preventing the html tags from rendering but when i use with prettify, it displays as a massive block of code without styles. Im sure there is something conflicting, but rather, are there any alternatives that are more popular for the fix im trying to attempt?
jsfiddle: http://jsfiddle.net/john_motyl/2QFnB/ (swap the id to see what im talking about)
Just to make sure you know that all syntax hilighting scripts add something like a span around bits of the code to colorize it, so it sounds like those elements are being converted by the escapeHTML script above and messing up the look.
prettyprint()before trying to escape the html entities. Thanks for pointing that out, i totally overlooked that. Now i call that function inside my if statement and it works perfect. Thanks