Getting Syntax Highlighting Working with Wordpress

Really this post is entirely for my own benefit and to merely test the Syntax Highlighter ComPress wordpress plugin that I’ve just installed.

This plugin “is based on the latest Alex Gorbatchev’s SyntaxHighlighter Script” and enables “Code and source text of different mark-up or programming languages to be highlighted.”.

Well here goes, here’s some C# code…

    /// <summary>
    /// A customer.
    /// </summary>
    public interface ICustomer
    {
        /// <summary>
        /// Gets or sets the customers first name.
        /// </summary>
        /// <value>The card request.</value>
        string FirstName { get; set; }
    }

And some SQL code:

SELECT * FROM vw_tblCustomer AS C WITH (NOLOCK)
INNER JOIN vw_tblTransaction AS T WITH (NOLOCK) ON C.id = T.id
WHERE Customer.FirstName IS 'oliver'

So it does seem to work, good stuff. Good points to note, I copied the code straight from Visual Studio, the < and > characters, that appear all over the place in comments, were automatically converted into &lt and &gt. Tabs from the copied code were also conviently converted into appropriate spaces.

Bad points, it isn’t immediately obvious how to turn off the line numbering. Actually, all you need to do is add “gutter: false;” to the pre tag class as follows:

<pre class="brush:csharp; gutter: false;">blah</pre>

Will probably persevere with this, unless I find something better.

Leave a Reply