Preserve Code Formatting v2.0
I’d like to announce the official release of the updated Preserve Code Formatting plugin (v2.0) for WordPress.
Preserve formatting of code for display by preventing its modification by WordPress and other plugins while retaining original whitespace and characters.
The plugin’s official homepage is located at :
http://coffee2code.com/wp-plugins/preserve-code-formatting.
This release debuts the admin options page for the plugin. The release also brings with it full compatibility with WordPress 2.3+ and 2.5.
This update is part of coffee2code’s 14 Days of Plugins (updated plugin #16).
Comments welcome on this post for this version of the plugin. Comments will be closed once this release has been superseded by another.
Read more for a detailed ChangeLog of the release.
Detailed ChangeLog
These are the detailed changes, which may or may not make sense to you depending on your familiarity with the previous features and internals of the plugin.
- Completely rewritten
- Now properly handles code embedded in comments
- Created its own class to encapsulate plugin functionality
- Added admin options page under Options → Code Formatting (or in WP 2.5: Settings → Code Formatting). Options are now saved to database, negating need to customize code within the plugin source file.
- Removed function anti_wptexturize() as the new handling approach negates its need
- Changed description; updated installation instructions
- Added compatibility note
- Updated copyright date and version to 2.0
- Moved into its own subdirectory; added readme.txt and screenshot
- Tested compatibility with WP 2.3.3 and 2.5

Hi,
I think this plugin works just fine, I like it a lot. Wordpress should have its own ‘code preserver’.
But I’m having problems with it. Weird enough, it is converting my code to non-ascii garbage, like this
$devom��fW”�FW67&�&�Т�РТV�6PТFFWf��fW”��РТ&WGW&�FFWf��fW#�Ч�
when it should be
$devomµçfW"ÒFW67&–&ó°Ð¢ÐРТVÇ6PТFFWföÇfW"ҰРТ&WGW&âFFWföÇfW#°Ð§ÐYou can see a “live example” here:
http://alvlin.com/php/3-manejando-archivos-ini
See? again it is eating my code!
alvlin: The problem you mention does seem to appear on occasion. I’m currently investigating the matter…
Hi, please edit my first comment and remove the link I put, as I’ve disabled the plugin in my site, waiting for a fix. I’m getting some visitors from here, and I don’t want them to think I’m a spammer
Anyway, you can see the problem in the code I pasted.
Regards.
I have been looking for such a plugins for years. It is simple and great.
My issue : ‘\’ disappear in code,
c:\windows in code = c:windows
have a check at
http://laurentschneider.com/wordpress/2008/05/preserve-code-formatting.html
note that using pre+code did have the effect of generatings symbols like above. also with some tags. Out of my hundreds of tags I renounce to us CODE and go to I to avoid the bug of alvin in maybe 2 or 3.
Thanks a lot!
Laurent
Hi Laurent,
thanks for your tip. this site is using pre+code, but mine is not.
I’m using only a code tag without any other tag inside the code snippet.
Hi Alvin,
What about backslash?
C:TEMPFILE.TXTRegards
Laurent
I’ve tried that, and yes, the plugin is eating the backslash.
Regards