New WordPress Plugin: Escape HTML
You may also using Syntax Highlighter. Server Side highlighter do the escaping job for you. Client side highlighter do not do this job. I am using Google Syntax Highlighter for WordPress, which is a client side Syntax Highlighter.
Download the Escape HTML WordPress plugin from WordPress.org.
More about posting codes online:
I am using these settings on my WordPress installation for avoiding any big problem. In theme's functions.php file, I have these lines:
Still, whenever I save any kind of code/scripts, I use HTML editor as this does not convert the code I have written. Visual editor tends to convert text according to some semantic. Quote conversion is a big trouble for those who posts code online. WP convert single and double quote to curly quotes to look it fancy, but this destroy the validity of code and it will not work when someone copy and paste the code to editor. So, wptexturize is disabled (remove_filter('the_content', 'wptexturize');).
Update: I saw in WP 2.8.4 version that wptexturize is not applied to 'pre', 'code', 'kbd', 'style', 'script', 'tt' tags. and it is same in newer version. So, can I use wptexturize now! Need to check.
Update (08-09-2010): Added support for 'code' and 'tt' tag. Code tag can be used for inline code whereas 'pre' can be used for block code.
Hope, you have enjoyed the plugin and post. Please share it!