Monday 6 October 2008

Adding Code Snippets to Blogger posts

In my previous post I wanted to include some sample code, but wanted to have highlighted and include line numbers. Well, after some scooting around, it seems I'm not the only one who wants be able to add "pretty" code snippets to some of my posts. I'm quite surpised that it hasnt been implmented as a piece of standard Blogger functionlality, but it's not, so the next best thing can be found at http://code.google.com/p/syntaxhighlighter/

This cool library allows you to use <pre> tags containing your code and it will add highlighting and line numbers to your snippets, for a variety of different languages, including Visual Basic, Python, CSharp and JavaScript. Nice.

If you want to see how to implement it on Blogger, have a look at Timothy Broder's blog GPowered. Give it a go, its well worth it.

No comments:

Post a Comment