Wednesday, November 12, 2008

Syntax highlight source code for Blogger

Just add this code fragment to your template

<link href='http://t800t8.googlepages.com/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://t800t8.googlepages.com/shCore.js'/>
<script language='javascript' src='http://t800t8.googlepages.com/shBrushCSharp.js'/>
<script language='javascript' src='http://t800t8.googlepages.com/shBrushJava.js'/>
<script language='javascript' src='http://t800t8.googlepages.com/shBrushXml.js'/>
<script language='javascript' src='http://t800t8.googlepages.com/shBrushSql.js'/>
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>

And write your source code inside this <pre> tag
<pre name="code" class="python">
// source code
<pre>

You can get the source code for SyntaxHighlighter here: http://code.google.com/p/syntaxhighlighter/downloads/list

No comments: