RBCode

rbcode is a WordPress plugin that allows you to insert beautifully formatted REALbasic code snippets into your posts and pages.
The code is based on a PHP class written a few years ago by a former employee of REAL by the name of Jonathan Johnson for phpBB but has been modernised and converted for use with WordPress.

rbcode has lots of nice features:

  • Keyword highlighting
  • Datatype value colouring (Strings, Integers, Colors and Doubles are individually coloured)
  • Comment highlighting (even inline comments)
  • Line numbers (optional)
  • Capitalisation of keywords (optional)
  • Code indentation. Elegantly handles if…endif, loops, select statements, etc
  • Safe code handling. WordPress won’t mangle your code snippet with funny HTML entities

 

Examples

All types of comments are dealt with. Notice how the Color data type value appears just like it does in the IDE:

// rbcode handles all three types of comments, like this double slash
' or this single quote
rem it even handles rem (who still uses this by the way??)

// Colours different data types
dim myInt as integer = 100
dim myDbl as double = 42.5
dim myString as string = "what a pretty colour"
dim myColour as color = &cFF0011

msgBox( "It deals with about 115 keywords at the last count!" )

Easily handles code indentation, with no limit to the number of levels of nesting:

// Don't worry about if…endif statements

if thisWorks then
   print( "Sweet!" )
else
   select case errorCode
   case true ' inline commenting
      a = b * 2
   case false
      // I think you get the point now…
   end select
end if

Line numbering and automatic keyword capitalisation:

00' You can globally (i.e. blog-wide) set the colours from the WordPress dashboard
01' You can also enable line numbers and/or auto-capitalisation of keywords either
02' globally or with the numbers="boolean" and caps="boolean" shortcode attributes
03
04If youLikeCaps Then
05   While something Not False
06      If a IsA frog Then ' huh?
07         someFunction( "Cool" )
08      Else
09         beep() ' why not?
10      End If
11   Wend
12End If

 

Installation

  1. Download and unzip the package.
  2. Upload the rbcode folder and it’s contents to wp-content/plugins
  3. Enable rbcode on your Plugins page in the WordPress dashboard
  4. Wrap your code snippets with rbcode /rbcode shortcodes to have rbcode highlight them
  5. You can customise the highlighting colours, line numbering and automatic keyword capitalisation from RBCode’s options page in the WordPress dashboard
  6. Have fun!

 

Requirements

Tested with WordPress 3.3.1. Should work on earlier versions. If there’s a problem then let us know.

 

Download

The latest version of rbcode is 1.1.1 and you can download it here:

 

Support

If you have any suggestions, have found a bug, would like to contribute or would just like to say thanks then please drop me an email or visit our forums.

 

Changelog

1.1.1 (11th May 2011)

  • Bug fix. #elseif is now correctly recognised as a keyword

1.1 (9th May 2011)

  • Added “numbers” and “caps” shortcode attributes

1.0 (8th May 2011)

  • Initial public release