25 September 2009


Seeing my first post published was accompanied by a healthy dose of feeling accomplishment. But soon I found that the script code left something to be desired.


After scouring the now humongous blogosphere I found people to relate to. But that's usually easy on the Internet. So after applying google-fu to the problem I found SyntaxHighlighter! Using it on Blogger requires a few simple steps which others have explained but I always try to do it my way so I learn something and memorize the process.

The gist of it is adding more javascript to your blog's HTML template. I appended my <head> section with this:
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> 
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js'></script> 
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js'></script> 
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js'></script> 
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js'></script> 
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'></script> 
<script type='text/javascript'> 
 SyntaxHighlighter.config.bloggerMode = true;

The javascripts parse any <pre> blocks in your blog post and display the code in a nice way. The default style clashes a bit with my blog template but I might fix that. What good is dabbling in vanity if it doesn't achieve its purpose? :)

So let me try Hello World again:
echo 'Hello, world!'
if [ $? -eq 0 ]
    ./comment > /dev/null
Reblog this post [with Zemanta]

No comments:

Post a Comment

Yin & Yang!