Geshi Supported Languages

Switch on the Code uses GeSHi (Generic Syntax Highlighter) to do all the code highlighing and formatting in tutorials. But it is also enabled for comments, allowing you to easily add nicely formatted code blocks to comments. How do you do this, you ask? Well, it is real easy!

For example, say you had some php code you wanted to put in a comment. All you have to do is write it like so:

[php]
if($this_is_great_code)
{
  echo "Yay!";
}
else
{
  echo "Boo!";
}
[/php]

And it will appear in the comment like this:

if($this_is_great_code)
{
  echo "Yay!";
}
else
{
  echo "Boo!";
}

So, as you can see, the only thing you needed to do is surround your code with [php] and [/php].

This works for a number of other languages as well:

  • Actionscript: [actionscript]
  • AutoHotkey: [ahk]
  • C++: [cpp]
  • C#: [csharp]
  • CSS: [css]
  • HTML: [html]
  • Javascript: [javascript]
  • MXML: [mxml]
  • PHP: [php]
  • Python: [python]
  • Ruby: [ruby]
  • SQL: [sql]
  • Text: [text]
  • XML: [xml]

For just general preservation of formatting, the [text] option is a good one to go with - so if you need to post code in a language that is not listed here, you should use [text].

Now go forth and leave some code in some comments!

Sponsors