WordPress Syntax Highlighter

This plugin enables you to highlight syntax using the PEAR Text_Highlighter class. Other syntax highlighters on the market either use GeSHi or JavaScript. While both solutions work, GeSHi places a heavy burden on the server and JavaScript dramatically increases the page size. This plugin gives you the speed and efficiency provided by the PEAR developers which reduces your page size and load time. You even have the option of enabling or disabling the line numbers as well as specifying your own style.

To use SyntaxHighlighter simply unzip syntaxhighlighter.zip and upload the syntaxhighlighter directory to wp-content/plugins. Then navigate to wp-admin in your browser under Plugins enable Ion Syntax Highlighter. Once the plugin is enabled you can use the [code] tags in your blog posts and highlight your code. You can also specify a language by using [code lang=”PHP”].

For example the following:

[code lang="PHP"]
<?php
echo "Hello, World!";
?>
[/code]

Will result in:

<?php
echo "Hello, World!";
?>

FAQ

How do I enable/disable line numbers?
Under the settings menu click on the Syntax Highlighter link. From there either select “Yes” or “No” to the Line Numbers option.

Characters are being converted to their HTML entities
This is because you have entered your code in Visual mode. You must enter your code in HTML mode.

This plugin breaks my XHTML validation.
This plugin encapsulates code using div tags. DIV is a block element and cannot be placed inside an inline element. This is probably causing your validation to break. If you place [code] tags inline, you are placing them inside a <p> which is an inline element. This causes your validation to break. Therefore you must place [code] tags on a line by itself. For example:
BAD

This is hello world in PHP: [code lang="PHP"]<?php echo "Hello, World!"; ?>[/code]

GOOD

This is hello world in PHP:
[code lang="PHP"]<?php echo "Hello, World!"; ?>[/code]

Screenshots

Highlighted Syntax

Highlighted Syntax

Administration

Administration

Download