I have finally found a code highlighter that works well in WordPress 2.x. iG:Syntax Hiliter makes use of the GeSHi engine.
An example from the palandrome program I posted about before:
-
using System;
-
-
public class Palandrome
-
{
-
static void Main(string[] args)
-
{
-
// initialize vaiables
-
int number;
-
int lft_most_number;
-
int lft_cntr_number;
-
int rght_cntr_number;
-
int rght_most_number;
-
int input_number;
-
-
// Put output about program to screen
-
Console.WriteLine("This program will test a 5 digit number to see if");
-
Console.WriteLine("it is a palandrome (that is a number that reads");
-
Console.WriteLine("the same forward and backwards, such as 12321).\n");
-
// Get input from user
-
Console.Write("\nEnter a 5 digit long number. -1 to quit: ");
-
input_number = Convert.ToInt32(Console.ReadLine());
-
number = input_number;
As you can see it puts the code in a nice box, and keeps it nicely formated (so long as you are not using the Rich Text Editor, also known as the WYSIWYG Editor). I have the option to show the language posted is turned on, but that can be turned off. I also left the option to use line numbers on as I like line numbers in posts like this. There is an option, as you can see to turn line numbers off and get a plain text view which won't be highlighted. The plain text option is another option that can be turned off by the admin, and can be set to open in a new window if the admin so chose. I like the range of options offered by the plugin, and more importantly that it works, and works well in WordPress 2.x. Most of my old ones seem to have been made for 1.5 and not updated.
To post a code snippet I put the language the code comes from in brackets [ and ], using both opening and closing tags. For exampe: [ csharp ] code here [ / csharp ], but without the spaces between the brackets and the csharp keyword. The nice thing is that it lets code left in the standard (X)html code tag alone. There is also an option to allow, which I did turn on, code highlighting in comments. So if somebody helps with a code problem I may present, they can have their code highlighted as well, by enclosing it in the same kind of tags. Another option that I have not used yet is the ability to tell it what line number it should start at on a code snippet.
I have went back and updated old posts to use the new plugin.


