//
you're reading...
Syntax Highlighter

Syntax Highlighter version 1.2

A new day (yesterday)* a new release of the syntax highlighter plugin.

This one adds support for line numbers; whether line numbers are displayed and the starting line number is controlled through attributes to the pre tag.

<pre lang=[cpp|cppcli|csharp|php|html|css|xml|xsl|text] 
  useLineNumbers=[true|false] startingLineNumber=[1|...]>
// Your code here
</pre>

Case doesn’t matter for the useLineNumbers or startingLineNumber attribute names but the values are case sensitive.

Download Syntax Highlighter v1.2 (23.9Kb). Installation is simple, extract the zip file to your WordPress installation directory and modify syntax_highlighter2.php the 'default' => 'csharp', line to tell the highlighter how it should colorize pre tags that don’t have the lang attribute set, or set to a valid value.

Once that is done you need to add some CSS classes to your sites stylesheet:

pre span.linenumber {
    color: gray;
    border-right: 1px solid gray;
}

pre span.comment {
    color: green;
}

pre span.keyword {
    color: blue;
}

pre span.number {
    color: red;
}

pre span.string {
    color: #990000;
}

Once that is done upload the files to your webserver and you should be ready to go.

*A New Day Yesterday, Stand Up – Jethro Tull

Advertisements

About James

I am a Senior Developer/Consultant for InfoPlanIT, LLC. I previously spent over 7 years as a Product Manager for what eventually became ComponentOne, a division of GrapeCity. While there, I helped to create ActiveReports 7, GrapeCity ActiveAnalysis, and Data Dynamics Reports.

Discussion

4 thoughts on “Syntax Highlighter version 1.2

  1. FYI:
    The link in your blog pointing to syntax_highlight_v1_2.zip does not work…

    Posted by torkar | May 17, 2004, 6:33 pm
  2. Thanks for the heads up, I’ve fixed the link.

    James

    Posted by James T. Johnson | May 17, 2004, 7:38 pm
  3. Ok I tested it and it works beautifully 🙂 (except for a minor detail)

    I use:
    pre lang=”csharp” useLineNumbers=”true”

    If I use:
    pre lang=”csharp” useLineNumbers=”true” startingLineNumber=”0″ then it looks really weird…
    Look here for an example, the second code snippet uses startingLineNumber and sets it to 0:
    http://java.thn.htu.se/~toor/blog-ng/index.php?p=316

    Notice the shift on the first line? Or is it my Mozilla?

    Posted by torkar | May 18, 2004, 5:45 am
  4. Hmm same thing happens when linenumbers go from 9 to 10:
    http://java.thn.htu.se/~toor/blog-ng/index.php?p=317

    Posted by torkar | May 18, 2004, 11:07 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archive

%d bloggers like this: