Handy Javascript Syntax Highlighter for Blog Posting

4:16 PM j. montgomery 6 Comments

After sharing my struggles with trying to format .NET code on my blog, my co-worker and friend jeff pointed me to this excellent must-have tool for bloggers who post code.

It's a Syntax Highlighter/formatter implemented in javascript so you don't have to mess with the complexity of posting code to your blog anymore. Just wrap your code in a <textarea name="code" class="c#"> and wow! It supports about 12 different languages including, but not limited to C#, VB.Net, SQL, XML.

See examples on my site here on my blog, or see every language sample here on the Syntax Highlighter web site.

kick it on DotNetKicks.com


  1. If you use Windows Live Writer to compose blog entries, you could also use the Code Formatter for Windows Live Writer by Steve Dunn. I believe the code formatter does the formatting at composition-time rather than at view-time. It's another option to consider at the very least.

  2. Hi Monty,

    I modified my template as said in here

    But still my blog looks the same, the SyntaxHighlighter has no effect. I compared your blog source with mine and I dint find much difference. I have no idea on web design and XML, so I am not able to fix this. Could you please help me fix this. This is my blog. Thanks.

  3. Arun - you'll need to add the javascript for C syntax...you've added the one for C#...

    Instead of referencing shBrushCSharp.js (C# support) you'll want to use shBrushCpp.js (for C and C++ support).

  4. This comment has been removed by the author.

  5. Indeed, when we refresh the page, the code is flashing on the post and goes off immediately.

  6. Hi Monty, I was using the "pre" tag instead of "textarea" tag.

    I just replaced the tag in my post to "textarea" and is working now. Thanks a lot.