How to highlight sourcecode in WordPress

The SyntaxHighlighter Plus plugin allows you to highlight different types of code within your wordpress posts:

CSS example

pre {
white-space: pre-wrap;       /* css-3 */
white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
white-space: -pre-wrap;      /* Opera 4-6 */
white-space: -o-pre-wrap;    /* Opera 7 */
word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

PHP example

<?php
$block = module_invoke('block', 'block', 'view', 7);
print $block['content'];
?> 

The module states it works upto WordPress 2.5 however it is working without any problems on 2.6.

It supports the following languages (the alias for use in the post is listed next to the name):

  • Bash — bash, sh
  • C++ — cpp, c, c++
  • C# — c#, c-sharp, csharp
  • CSS — css
  • Delphi — delphi, pascal
  • Java — java
  • JavaScript — js, jscript, javascript
  • PHP — php
  • Python — py, python
  • Ruby — rb, ruby, rails, ror
  • SQL — sql
  • VB — vb, vb.net
  • XML/HTML — xml, html, xhtml, xslt

Leave a Reply