WordPress’s Syntax Highlighter Evolved messes up my code

I use email to post entries to my blog. I place code snippets in between “LEFT BRACKET plain RIGHT BRACKET” and “LEFT BRACKET /plain RIGHT BRACKET” with the “div” tag surrounding them. My code gets displayed fine using the Syntax Highlighter Evolved plugin. However, when I edit the entry in wordpress, quotes, ampersands, less than signs, and greater than signs get converted to html code when I save the post and it makes my code unreadable. This also happens if I start writing my post in wordpress. This only happens to text within the code chunk, and not text outside of it. This conversion that happens when saving does not happen when the plugin is disabled. I did not find a fix for this.

To edit my posts with code and not have them messed up when saving, I have to disable the plugin before editing and re-enabling after editing. This is a pain.

For the previous posts that are already messed up, one can execute a sql script to replace the funny html code. For me, I edited each post manually in emacs and made use of this function:

 <pre class="example">(defun undo-html-char ()

(interactive) (beginning-of-buffer) (replace-string “<” “<“) (beginning-of-buffer) (replace-string “>” “>”) (beginning-of-buffer) (replace-string “&” “&”) (beginning-of-buffer) (replace-string “”” “\””) (beginning-of-buffer)

About Vinh Nguyen

Statistician

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>