Oct20

Syntax Highlighting with Wordpress

at 7.43pm

No programming blog is complete without decent syntax highlighting so it seemed reasonable to expect there to already be a good plug-in available to provide the functionality I need. Sure enough, a quick search resulted in finding WP-Syntax. The plug-in is based on GeSHi which started as the syntax highlighter for phpBB and is now a fully independent project with support for most major languages.

As a demonstration (and a test) here’s some PHP:

public class Foo {
   public function __construct($bar) {
      echo 'Hello World!';
   {
}

and some CSS (with line numbers):

1
2
3
4
   .foo {
      color: #FFFFFF;
      height: 100px;
   }

I think that’s enough of a demonstration and promotion of the previously mentioned projects but expect to see some code related posts in the not-to-distant future.

Reader Comments

  1. Alastair wrote:
    November 2nd, 2008 at 11:25 pm

    I use GeSHi too on my site – there’s a Drupal module too. Works like a treat, and you can customise your syntax highlighting via CSS to match your favourite IDE, too :-)

Comment on This Post

The XHTML tags <a>, <abbr>, <acronym>, <b>, <blockquote>, <cite>, <code>, <del>, <em>, <i>, <q>, <strike>, <strong> and <pre> can be used in your comment. Your e-mail address will not be displayed.

* Required field

This Post

This entry was posted on Monday, October 20th, 2008 at 7:43 pm in Site Updates, Web.

You can leave a comment below or trackback from your own site. Discussion can be followed through the entry's RSS 2.0 feed.