Wednesday, June 17, 2009

Syntax Highlighting in Wordpress.com blog

I have to admit that I am a late adopter. While I see my peers in JUG community already using syntax highlighter in their blog post, I was just discovered how to do it.

In order to do it, you need to use the

[sourcecode lang="<language>"] tag:
[sourcecode language="xml"]


burger


[/sourcecode]

Above code is using lang="xml".

For Java code snippets you could highlight it pretty easily using the lang="java" with the tag.
[sourcecode language="java"]
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
[/sourcecode]

I am just really excited on how it works. I think Alex Gorbatchev has done a great job on the syntax highlighter!

1 comment: