/ xojo

Xojo GeSHi Language File

I'm pleased to announce the release of a free custom language file for GeSHi for the Xojo programming language. GeSHi (the Generic Syntax Highter) is a PHP library that can highlight the syntax of a number of programming languages. It's also available as a plugin for WordPress (as WP-Syntax). This language file adds support for Xojo to the highlighting engine.

Why might I use this?

If you blog about Xojo, you'll probably want to display some example code. If you use Wordpress, you can use a combination of the WP-Syntax plugin and this language file to highlight Xojo code in your posts.

How do I use it?

Simply install the WP-Syntax plugin and then add the Xojo language file to the geshi folder within the wp-syntax folder of the plugin. Then just wrap any Xojo code in your posts with <pre lang="xojo"></pre> tags and the plugin will highlight the code. You can also optionally add line="1" to show line numbers (omit to hide them). Adding highlight="4" will highlight the fourth line of code.

What does it support?

The language file supports almost everything that the Xojo IDE does. It will correctly highlight the following items in code (in the default Xojo IDE colours):

  • Keywords (current up to Xojo 2014 release 2.1)
  • Primitive data types
  • Integers
  • Floating point numbers
  • Strings
  • Comments
  • Hex, binary and octal representation of numbers

Known issues

  • Currently unable to highlight URLs within comments like the Xojo IDE does
  • Does not highlight the individual red, green and blue components of a &c (color) literal data type


GeSHi requires that CSS styles for each highlighted component in a syntax are hard-coded into the language file. At present, these colours mimic those chosen by default in the Xojo IDE:

  • Keywords (#0000FF)
  • Strings (#6500FE)
  • Integers (#326598)
  • Floating point numbers (#006532)
  • Comments (#7F0000)
  • Hex (&h) numbers (#326598)
  • Binary (&b) numbers (#326598)
  • Octal (&o) numbers (#326598)

Within the language file, I've separated Keywords (such as Dim, While) from primitive data types (e.g. Double, String) and compiler directives (e.g. #pragma, #If) so you can style them differently if you'd like. By default, they have the same styling (color: #0000FF) as keywords.

To change a style, simply change the CSS style property for the type (e.g. KEYWORDS) within the STYLES array in the PHP language file.

Further tweaks

I dislike GeSHi's default behaviour of adding alternating line colours so I added the following custom CSS to my Wordpress theme stylesheet to remove it:

/* Remove the alternating line background colours in code (added by the WP-Syntax plugin) */
.wp_syntax pre {
    background: #FCFCFC !important;
    font-size: 1.1em !important;
    line-height: 1.4em !important;

.wp_syntax td.code {
    background-image: none;
    background-color: none;


The file is hosted over on GitHub.


If you find the file helpful then please let me know in the comments below. If you're able to help to improve the file (e.g. by adding support for &c colours - you'll need to know a little bit of regex) then make a pull request on the official GitHub repository.