Sunday, August 27, 2006

Syntax Highlighting with GeSHi and csh_geshi plugin

Pasting code in Wordpress is not an easy task, Wordpress will tend to mess it up by applying filters to it. The GeSHi (Generic Syntax Highlighter) project not only prevents that, but also provides syntax highlight as well. To use it, you will need a Wordpress plugin. The WordPress csh GeSHi Plugin does that job well, the syntax is easy and is easily configurable. You will have to disable Wordpress's rich text editor though, at least when you need to paste code samples.

Some examples of the combination in action.

Simple:
[js]
function square(num)
{
return num*num;
}


With line numbering:
[java,Y]
public class Student
{
private String name;
private String matricNo;


public Student(String name, String matricNo)
{
this.name=name;
this.matricNo=matricNo;
}
}
Start line numbering from 10
[sql,Y,10]
select * from product where price>100 and type='ELECTRONICS';
select * from staff where name like '%JOHN%';
select * from store where manager='HENRY LEE';

1 comment:

  1. My first time to know about this plugin. WordPress csh GeSHi Plugin? It really sounds new to me. I will review more about it first before installing. Thanks!

    ReplyDelete