publishing code in WordPress

WordPress blog engine automatically adds typography to postings. For example, it changes two dashes to the long dash, changes the usual quotes to different sorts of quotes. And yes, code listings are affected.

You understand how it’s annoying. Finally, I decided to fix it. Before doing it myself, I looked into WordPress plugin repository, and, surprise, I found what I need.

Plugin: Code Auto Escape
Description: Automatically escape code within <code>…</code> tag

Description misses very important notice: “and hides content from WordPress text filters”.

And I don’t need escaping, so I’ve modified the code a bit:


--- codeautoescape.php      2006-06-02 08:30:45 +0400
+++ codeautoescape.php.orig 2006-06-02 08:30:38 +0400
@@ -67,7 +67,7 @@
 add_filter('content_save_pre', 'pri_cae_mask', 28);
 add_filter('content_save_pre', 'pri_cae_unmask', 72);
 add_filter('the_content', 'pri_cae_mask', 1);
-add_filter('the_content', 'pri_cae_unmask', 99);
+add_filter('the_content', 'pri_cae_unmask_replace', 99);

 add_filter('excerpt_save_pre', 'pri_cae_mask', 28);
 add_filter('excerpt_save_pre', 'pri_cae_unmask', 72);

Leave a Reply