Guide to find a WordPress syntax highlighter that works

Previously, I complained about how I needed a syntax highlighter and have no recommendations… I hand tested and create a review on some of the popular choices I found on plugin directory. The plugins I listed are base on following requirements:

  • Supported in WordPress 2.7.1
  • Last updated in 2009

The criteria to the syntax highlighter I am looking for based on below 2 points:

  • Code remains unchange after a post is been edited in either Visual mode or HTML mode
  • Read to use out of the box. I should be able to use it with no or little configurations

SyntaxHighlighter Evolved

Last Updated: 2009-5-4 (Version 2.1.0)

Syntax: Visual. Eg/ [php], [javascript]

One of the feature of SyntaxHighlighter Evolved is its elegant toolbar on the corner of the code block, which allows you to choose between: View code in a pop up, copy code to clipboard or print code. For some reason Syntax highlighter Evolved likes to strip away my indents (spaces) in my code. If I tried to save in HTML mode, I will get PHP warning messages as well as have my code striped from my post. Overall, this plugin does not perform the way I wanted.

p06-syntax-highlighter-evolved

p06-syntax-highlighter-evolved-02

Syntax Highlighter Plus

Last Updated: 2009-2-11 (Version 1.0b2)

Syntax: Visual. Eg/ [sourcecode language='css']

Like other plugins of Syntax Highlighter family, it come with a toolbar, and like Syntax Highlighter Evolved it failed on the same way: Strips my indents and remove my code when I tried to save in HTML mocde.

p06-syntax-highlighter-plus

Google Syntax Highlighter for WordPress

Last Updated: 2007-8-14 (Version 1.5.1)

Syntax: HTML. Eg/ <pre name=”code” class=”php”>

Despite it has not been updated for almost 2 years, Google Syntax Highlighter seems to be the popular choice by bloggers, so I decide to include this one in the test. Google Syntax Highlighter comes with a texture toolbar, not as fancy as Syntax Highlighter family but does its job. Appearently there is a styling issue when dealing with long line of code but that won’t matter much since the plugin fail siliently when I switch between Visual mode and HTML mode: loss indent and syntax color. Another disappointed candidate.

p06-google-syntax-lighlighter

p06-google-syntax-lighlighter-02

WP-Chili

Last Updated: 2008-7-24 (Version 1.1)

Syntax: HTML. Eg/ <code class=”php”>

WP-Chili is another special candidate, which has been recommanded in another WordPress syntax highlighter review, I will also give this one a try. Unlike all previous candidates, it required manual character escaping. I uses Elliot’s postable script (as recommanded) to do the job. Simplier styling that may requires few tweaks (such as fix long line wrapping and give it a background color or border to distinguish from normal paragraph). WP-Chili actually survived after test saving in both Visual mode and HTML mode, unfortunately my indents went missing after few saves… Does no one likes my space indents?!

p06-wp-chili

Code Colorer

Last Updated: 2009-1-27 (Version 0.7.3)

Syntax: Both Visual or HTML. Eg/ <code lang=”php”>, [cc lang="php"]

Now a fairly new plugin I found in the directory. For some reason I can not get the code showing correctly despite I able to inspect the HTML code using firebug.

p06-code-colorer

Dojox WordPress Syntax Highlighter

Last Updated: 2009-1-27 (Version 0.7.3)

Syntax: HTML. Eg/ <pre><code class=”php”>

Dojox is the first plugin that manage to survive the test: code remain the same after multiple saves in different mode. Dojox uses a double tagging syntax and requires manual character escaping. Background color may need a change to fit blogger’s theme but besides that, it is a working pluging (finally).

p06-dojox

Syntax Highlighter and Code Colorizer for WordPress

Last Updated: 2009-5-5 (Version 2.0.296)

Syntax: HTML. Eg/ <pre class=”brush:php”>

Appearently it is also known as Code Prettifier. Code Colorizer does auto wrapping by default and has a toolbar on top right corner as it is another member of Syntax Highlighter family. One important different to its family is it actually works! No problem when saving post in Visual mode nor HTML mode, however you will require to manually escape your code.

p06-code-colorizer

WP-SynHighlight

Last Updated: 2009-1-27 (Version 0.91)

Syntax: Visual. Eg/ [codesyntax lang="php"]

This plugin is the only plugin I found that works and uses Visual syntax and won’t break if you switch between different modes. And since you pasting your code in Visual mode, there is no need to escape the characters, which is an advantage of posting in Visual mode. But somehow I got no coloring from WP-SynHighlighter even if I follow its example.

p06-wp-synhighlight

Conclusion

Syntax Highlighter and Code Colorizer for WordPress won my vote as it is easy, robust and actually works. The plug in is out of the box, which means I do not need to dig into CSS restyle its color schema to fit in my theme. I know I will enjoy making my switch!

Tags: , , , ,

6 Comments

  1. Cody said on August 16th, 2009

    Thanks for reviewing these syntax highlighters. Finding one was such a pain and the Google Syntax Highlighter just didn’t work for me. I followed your recommendation and tried Syntax Highlighter and Code Colorizer for WordPress, which works perfectly :)

  2. Travis said on August 16th, 2009

    Hi Cody,
    I’m glad that it helps! :D
    I’m sure syntax highlight won’t be much of a headache soon, as a default syntax highlighter is provided by WordPress 2.8!

  3. FractalizeR said on January 6th, 2010

    >>But somehow I got no coloring from WP-SynHighlighter even if I follow its example.
    You just forgot to read FAQ :)
    You need to start PHP code with PHP tag “<?php". And highlighting will be ok.

    I also released 2.0 version of my plugin: http://wordpress.org/extend/plugins/wp-synhighlight/ with full GUI mode source code editing.

  4. alswl said on March 19th, 2010

    Thank you very much~
    I hava translated this post to Chinese.
    See here: http://dddspace.com/2010/03/guide-to-find-a-wordpress-syntax-highlighter-that-works-translation.html

  5. Victoria Young said on May 14th, 2010

    i host 5 of my blogs on Blogspot and it is really good for beginners. but if you want something with more features, nothing beats wordpress:-:

  6. Techs24x7.com said on June 2nd, 2010

    In my BLOG i hv installed/enabled syntax highlighter … still it is now working for SQL commands ..

    Can anyone pleae help me out ???

Leave a Reply

Trackbacks

  • Pages

  • Categories

  • Archives

  • Recent Comments

  • Tag Cloud