HTML Escape Parser
While doing some posts just recently, I realised if I want to do a full HTML post then it makes it hard to actually include code. It get's tedious having to go through and escape every bracket and all that crap.
I will update this and post revisions and will include the hard code of the PHP script and ajax when I have polished it a bit more. Its pretty raw at the moment.
Anyway, click through to have a look and try it out. Please comment if it doesn't work or you find there are errors! There is only so much that one man and his imaginary dog can test!
Enter in the HTML code and click submit
Comments
Revisions
Ok so I finally cracked the mongrol. For those wanting to replicate an app like this you can do 2 things.
Use my publicly available script (not yet on googledocs but will get that up asap)..
elliottfox.com/htmlParser.php?htmlContent=xxx
where xxx use a string containing the html you want escaped. It will return (just echo'd) the escaped html.
For those who want to download and do it yourself here is the code:
<?php$html=$_GET['htmlContent'];
$html=htmlspecialchars($html);
$html=preg_replace('/&/','&',$html);
echo $html;
?>
you will notice i escape the html chars, and then go through and replace the & symbol. This is because if you dont escape the & symbols twice, all the escaped chars will just print as their html equivilant. Pretty obvious now but it took me an hour to figure out how to get that part to work.