Posts tagged "syntaxhighlighter"

Coda theme for SyntaxHighlighter

It's no secret – I love Coda! It's a pleasure to use. It looks so damn good. When I started using SyntaxHighlighter I set out to create a Coda theme. Thankfully, the good folks at Panic had done the ground work for me. All I had to do was create a style sheet that would make my code snippets look as sexy online as they do in my text editor.

Or so I thought.

Prototype loader for SyntaxHighlighter

SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript (as stated on its wiki). One of its deficiencies is that it retrieves all its brushes each time a page is loaded, despite the fact that in many cases only one or two (or none) are required.

Currently, Prototype is my JavaScript framework of choice (although I'm really looking forward to trying jQuery). I have used Prototype to create a brush loader for SyntaxHighlighter, which retrieves brushes on demand to reduce page loading times (in certain circumstances).

|| date: 27 June 2009 || time: 6:21am || || I have completely rewritten the code so that it no longer requires || empty functions inside the brush files to act as indicators of readiness. || Instead, the required brushes are retrieved in a daisy chain. This is both || more elegant and more reliable. Additionally, style sheets are now also || retrieved on demand.

PHP brush for SyntaxHighlighter

Alex Gorbatchev's SyntaxHighlighter is a well-written bundle which enables syntax highlighting of code via JavaScript. More than twenty languages are supported "out of the box", and brushes (JavaScript files containing language-specific regular expressions) can be created to support additional languages.

Unfortunately, however, several of the brushes that come bundled with SyntaxHighlighter are far from perfect. Have a look at the bundled PHP brush in action below.

Screenshot of PHP code highlighted by SyntaxHighlighter's PHP brush
Screenshot of bundled PHP brush in action

AppleScript syntax highlighting

I've been using Alex Gorbatchev's SyntaxHighlighter to syntactically display code of various languages for several months now. When I decided to post an AppleScript snippet, however, I realised that I was out of luck. SyntaxHighlighter does not include an AppleScript "brush", and a quick flick through the SyntaxHighlighter forums did not bring me any joy.

How hard could it be to write a brush for AppleScript?, I wondered. The handy guide to developing a custom brush got me started, and I was soon busy trying to encapsulate AppleScript's syntax -- along with its keywords and countless words and phrases with special meanings -- into a handful of regular expressions.