Wednesday, January 21, 2009

Syntax Highlighting Posted Code Snippets

For years, I have struggled with how to share my code snippets on the web. I wanted the "fancy" look, but I didn't want to waste a bunch of time converting my code to html/css.

I'd see some sites that had a nice look, but when I looked under the covers, they were invoking proprietary server side engines to generate the the "pretty print code".

Today, I found the answer on GoogleCode: Syntaxhighlighter, a free DYNAMIC Javascript-based syntax highlighter.

The custom CSS for sourcecodetable is mine. The only change that I made was to go...


<pre class="sourcecodetable">
... some C# code here ...
<pre name="code" class="C#">
... some C# code here ...
It supports:
  • C#
  • Java
  • XML
  • PHP
  • Python
  • SQL
  • VB
  • C++
  • CSS
  • Html
  • Delphi
I'm really impressed with how well it looks.



No comments: