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 :
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
19 replies on “Preserve Code Formatting v2.0”
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
You can see a “live example” here:
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…
Thanks for another great plugin. I am having one small problem though… all my forward slashes seem to stripped out such that a new line becomes ‘n’. ie:
print "\nRunning script...";
becomes
print "nRunning script...";
Doh!, the plugin stripped the slash from my example .. let’s try:
print “\nRunning script…”;
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
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:\TEMP\FILE.TXT
Regards
Laurent
I’ve tried that, and yes, the plugin is eating the backslash.
Regards
Just wanted to tell you that 0.9 version of this plugin is redirecting me to Random File plugin in the WP Plugins page (to upgrade).
Thanks for this great plugin!
Hey, wonderful plugin, simple are exactly what I want.
Just thought I’d let you know that the automatic upgrade for your code preserve plugin doesn’t work well..instead of installing the newer version of code preserve it installs another plugin..
Just thought I’d let you know.
Regards
mike
To preserve the backslashes, you can edit the preserve-code-formatting.php, and replace the lines:
to:
and
to:
It works for me.
Eeek… any news on fixing the backslash issue?
Hi Scott,
a great plugin indeed. I used it with a recent WordPress MU and it works very well with one small caveat: when combined with WP-Syntax, your plugin eats up the language attribute of
<pre lang="ruby">
.I did two small modifications to your plugin which helped. The modified lines are:
(removed angle bracket)254: if (preg_match("/^<{$tag}([^>]*>.*)<\\/{$tag}>/Us", $code, $match))
(moved parenthesis)and
Regards
MiSky
It’s still not working in WP 2.7. Keeps changing code into garbage. Fail. Same issue as Alivin
[…] maybe, you know, the programmers of WordPress itself… I’m currently trying to fix this plugin to not kill […]
I’ve downloaded the preserve code formatting plugin, but I don’t know how to use it, for some reason I can’t figure it out. Wonder what my problem is?
Brooke
This plugin has been updated to v2.5
Please direct any further questions and comments to the page announcing that release (or from the plugin’s homepage, find the post related to the most recent release).
The issues and suggestions mentioned in the above comments should all have been addressed in this latest release.