Wednesday, February 1, 2012

Programming Language Syntax Highlighting with Blogger Engine

We can enable the Syntax highlighting for the Programming language code in the blogs using "Syntax Highlighter" JavaScript Library.

We can achieve that with the following steps.

1. Adding Syntax Highlighter library to blogger template.

Copy the following code.

















paste it into your Blogger Template just above the tag.
Save the template.
Then you can start creating code blocks in your existing or new Blog entries.
There are 2 ways to add a code block using syntaxhighlighter.

Method 1 : Using script tag




becomes

// Comment
public class Testing {
public Testing() {
}

public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}


Method 2 : Using pre tag
// Comment
public class Testing {
public Testing() {
}

public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}
becomes

// Comment
public class Testing {
public Testing() {
}

public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}


Ref::
http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html