2011/05/21

Enable Code Syntax Highlighting on Blogger

Paste following 2 lines into your HTML template:

<link href='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css' rel='stylesheet' type='text/css'/>
<script src='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js' type='text/javascript'/>


Modify <body> to <body onload="prettyPrint()"> . Remember to keep other body attributes if any.

When posting, enclosing your codes between <pre class="prettyprint"> and </pre>, and that is done. PrettyPrint will automatically detect the programming language in which the code is written.