Wednesday, February 3, 2010

Oh, bloody glorious syntax highlighting

Finally! I've found a syntax highlighter that works great in Blogger!

Alex Gorbatchev has done a great job putting together the SyntaxHighlighter.

And Carter Cole has put a nice article together for how install it in your Blogger template.

For my own reference, here's what I do.
<pre class="brush: php">
echo "sweet sweet syntax highlighting"; 

Results in

echo "sweet sweet syntax highlighting";

Update: 24-Oct-2011. Originally, this used a <script> tag and a special type. I've since come the conclusion that it does not degrade nicely, and it's better to use <pre> tags. Fortunately, the same syntax highlighter still works. I just need to revisit all my code and make sure it is escaped appropriately.

No comments:

Post a Comment