What it does:
SyntaxHighlighter adds support for the most excellent dp.SyntaxHighlighter from Alex Gorbatchev for easy use in your WordPress. In it’s own words, SyntaxHighlighter “is meant to help a developer to post code snippets online with ease and without having to worry about applying format.”

Which it does pretty swell, but sadly, this didn’t quite work out on WordPress and it’s various display-filters, which are were quite annoying regarding this task. Now they aren’t anymore. And even the usage of SyntaxHighlighter got easier by using own tags and administration options.

Usage:

[ source:str language] str source [/source]

Please take note to NOT use a whitespace in the [ source:]-command like shown in Usage and Example. So if you copy & paste it, don’t forget to remove the space.

  • str language tells the parser how it should highlight the following source. Currently, the following strings are understood:
    • css
    • c#, c-sharp, csharp
    • c, cpp, c++
    • vb, vb.net
    • delphi, pascal
    • js, jscript, javascript
    • php
    • py, python
    • ruby
    • sql
    • xml, xhtml, xslt, html, xhtml
  • str source contains the source-snippet you want to display.

Example:

[ source:php]
// Re-insert source as (formatted) textarea
foreach( $theSources[2] as $sourceID => $sourceBlock ) {
    $theBrush =
        $theSources[1][$sourceID].$optionString;
    $thePost = str_replace(
        ”{sourceID:{$sourceID}}”,
        sprintf( $textArea, $theBrush, $syntaxOptions['syntaxCols'], $syntaxOptions['syntaxRows'], $sourceBlock ),
        $thePost
    );
}
[/source]

will become

[source:php]
// Re-insert source as (formatted) textarea
foreach( $theSources[2] as $sourceID => $sourceBlock ) {
$theBrush =
$theSources[1][$sourceID].$optionString;
$thePost = str_replace(
“{sourceID:{$sourceID}}”,
sprintf( $textArea, $theBrush, $syntaxOptions['syntaxCols'], $syntaxOptions['syntaxRows'], $sourceBlock ),
$thePost
);
}
[/source]

Don’t forget to activate support for the language(s) you want to display. Do this by going to the WordPress-Administration Options-Menu and click it active.

Supported languages:

SyntaxHighlighter currently supports:

  • C#
  • CSS
  • C++
  • VB & VB.NET
  • Delphi, Pascal
  • Java
  • JavaScript
  • PHP
  • Python
  • Ruby
  • SQL
  • XML, HTML, XSLT and any other XML style code

To keep things slim and pretty you can turn on or off every supported language in the WordPress Options, just like you wanted to ask for anyway.

Administration options:

When activating the plugin, you may notice a new administration menu under Options named “Syntax”. Here you can choose which languages should be supported and define some global display options, which are as follows:

  • Textarea Cols / Rows: will set in which dimensions the source-block is displayed first while CSS is not yet loaded.
  • Make the Textbox Collapsible? If activated, your sourceboxes will be collapsed at first, so your users will have to click them open to see the source.
  • Hide Controls on top? If activated, this option will hide the controls over your sourceboxes. These controls are show bla, print and a bit of info about the original SyntaxHighlighter-script.
  • Hide Gutter? If activated, this option will hide the line-counter to the left.
  • Hide Columns? If activated, this option will hide the column-counter which would otherwise appear above your source.

Download & Installation
Download:
Go ahead and fetch it here: syntax.zip

Installation:
Extract all files and directories from the .zip-archive to your WordPress plugin-folder. Then browse to your administration menu named “Plugins” and activate the plugin named “SyntaxHighlighter”. That’s it.

History:

1.3.0 Replaced textarea-functionality with the all new & simple [source]-command
1.2.1 Fixed a bug in RegEx which sometimes didn’t parse the posting correctly
1.2.0 Added some more admin options for easy one-time configuration
1.1.2 I wish I’d get a Dollar for each fixed incompatibility with WordPress
1.1.1 Fixed even more incompatibility with WordPress when having HTML-entries
1.1.0 Added admin options & dynamic script loading
1.0.0 Final Release
0.1.1 Fixed incompatibility with WordPress’ auto-p and texturize-filters
0.1.0 Initial Test Release.