Any good syntax highlighting plugins out there?

UPDATE (05/14/2009)
I spent a few hours checking out some new syntax highlighter plugins. The best I found was Syntax Highlighter and Code Prettifier Plugin for WordPress. I tried it for a few days, but it loads extremely slow and the styling is not inline (therefore your RSS feeds will not look pretty). After being frustrated again with the options out there, I updated wp-syntax and removed my hacks. It looks a lot better now, but there is still an issue with understanding quotes in regular expressions as you can see here. For now I will just submit a bug and not worry about it. I just wanted to mention that I believe wp-syntax is the best option available.

Original Post:
When I first started this blog just a few months ago, my code snippets were ugly. After evaluating a few syntax highlighting plugins, I chose wp-syntax because it is pretty well documented for a Wordpress plugin and has over 10,000 downloads. It was also nice to see screen shots before installing.

The wp-syntax plugin is based on GeSHi, a syntax highlighter written in PHP. GeSHi is cool because it supports a wide variety of languages. However, I did not like the default styling provided by GeSHi for any languages and it has bad syntax support for Ruby.

Any suggestions for a good syntax highlighting plugin would be GREATLY APPRECIATED! For now, I went into the source code and fixed most of the issues with Ruby syntax support, as well as altered styles and added more keyword support for PHP, Ruby, and CSS. It’s an ugly fix but I wanted to get it done quickly.

If you like the way my code looks here, do the following:

  1. Install wp-syntax (follow link for installation directions)
  2. Download my versions of geshi.php, ruby.php, php.php, and wp-syntax.css from this link
  3. Replace “wp-content/plugins/wp-syntax/geshi/geshi.php” with my version of geshi.php
  4. Replace wp-content/plugins/wp-syntax/geshi/geshi/(php.php, ruby.php, and css.php) with my versions of php.php, ruby.php, and css.php
  5. Put my wp-syntax.css in wp-content/themes/your_theme_name/ (wp-syntax knows to look here to override their default stylesheet)
  6. Add this to your Wordpress theme’s style sheet (probably styles.css):
    1
    2
    3
    4
    5
    6
    
    pre
    {
        font-size: 11px;
        background-color: #090909;
        font-family:  Monaco, Verdana, Arial, Lucida Grande;
    }
  7. To format your code blocks, just wrap your code as described in the documentation (using the pre tag).

I would probably do a more comprehensive improvement if GeSHi was not currently being rewritten; or if I didn’t have faith that I will stumble across something better soon ;)

No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

If you enjoyed this post, make sure you subscribe to my RSS feed!

This entry was posted in Software and tagged , , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.