Syntax Highlighted Blog Code Snippets

October 12, 2008

I recently came across a blog which had excellent code snippets. They had line numbers, syntax highlighting, and could be copied directly to the clipboard. After doing a bit of Googling, I finally came across syntaxhighlighter which enables these features with a could of lines of JavaScript and CSS and an extra two paramters on your <pre> tags.

Here’s an example:

<pre name='code' class='python>
print "Hello, World!"
</pre>

</code>

which produces:

print "Hello, World!"

</code>

Now my snippets will have some visual beauty and will hopefully be easier to work with. For those of you pasting code in your blogs, I highly recommend this.

:EXTENDED:

Syntax Highlighted Blog Code Snippets - October 12, 2008 - Jack Moffitt