Monday 2 March 2009

Code snippets on blogger

I decided to adjust the way I display code snippets on my blog. The old way of displaying wasn't very good and required some additional formatting. I've found a perfect solution for that: Syntax Highlighter. This allows you to easily display code snippets in a nice and accessible way. The code is colorised according to its type: e.g.

Xml:


sample

Java:
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}

The usage is really simple. In addition all required CSS an JavaScript files are available online so you can refer them from your blogger page! Can't wait to submit some more code ;)

Quick Note: When using this on blogger you'll need to turn the bloggerMode on. You can do it in JS:
SyntaxHighlighter.config.bloggerMode = true;
.

3 comments:

Unknown said...

Dzięki Filip! Już od jakiegoś czasu przymierzałem się do wdrożenia SyntaxHighlighter na moim blogu, ale dopiero po Twoim wpisie w końcu to zrobiłem. Tak krótko i interesująco przedstawiłeś temat, że nie mogłem się powstrzymać, aby spróbować samemu ;-) Teraz śmiga cudnie.

Jacek
Notatnik Projektanta Java EE

Amey said...

Syntax highlighter is rather a tough job and need to get everything in place

You may even check the following link, may be this should help

http://www.blogpandit.com/2009/05/add-code-snippet-to-blogger-mystery.html

Jaroslaw Dobrzanski said...

Mnie też przekonałeś. Co prawda korzystam z Wordpressa, ale też zainstalowałem ten plug in. Dzieki.