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...

From:

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

Link: http://alexgorbatchev.com/wiki/SyntaxHighlighter

Link: http://geektalkin.blogspot.com/2009/11/embed-code-syntax-highlighting-in-blog.html

No comments: