Changing the language of a DIR-615 KockFest 2010

Source codeMy Wordpress powered website has been running for quite some time now, and today I finally replaced the default theme with something I like better,  Suffusion, and customized it to my needs.

I had installed some syntax highlighting plugins before but disabled them because I couldn’t get it to work properly. Now with the pretty new layout all posts with snippets of unhighlighted source code were a real eye-sore, so that needed to be fixed as wel.

For some unknown reason the SyntaxHighlighter Evolved plugin that I couldn’t get to do as I wanted before now works like a charm. The only difficult part was to get me some AppleScript highlighting. David Chambers has written a brush, so I only had to install that brush the proper way. Creating the plugin was easy:

<?php
/*
Plugin Name: SyntaxHighlighter Evolved: AppleScript Brush
Description: Adds support for the Applescript language to the SyntaxHighlighter Evolved plugin.
Author: Ronald Chu
Version: 1.0.0
Author URI: http://www.rchu.nl/
*/

// SyntaxHighlighter Evolved doesn't do anything until early in the "init" hook, so best to wait until after that
add_action( 'init', 'syntaxhighlighter_applescript_regscript' );

// Tell SyntaxHighlighter Evolved about this new language/brush
add_filter( 'syntaxhighlighter_brushes', 'syntaxhighlighter_applescript_addlang' );

// Register the brush file with WordPress
function syntaxhighlighter_applescript_regscript() {
 wp_register_script( 'syntaxhighlighter-brush-applescript', plugins_url( 'shBrushAppleScript.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );
}

// Filter SyntaxHighlighter Evolved's language array
function syntaxhighlighter_applescript_addlang( $brushes ) {
 $brushes['applescript'] = 'applescript';
 $brushes['osascript'] = 'applescript';

 return $brushes;
}
?>

But at first the highlighting did not work on AppleScript snippets, and it took me quite some time to find out that I shouldn’t have copy-pasted the javascriptcode into Vim on my ssh shell. Some of the special characters in line 37 were transformed into in a question mark which broke the regular expression.

Now, as far as I know, only one thing is wrong; when I refresh quickly in Chrome (5.0.342.7 beta, OS X 10.6.2) some of the keywords do not light up. I do not know if it is a bug in Chome, SyntaxHighighter or the AppleScript brush, but it is something I can live with for now.

Leave a Reply

(required)

(required)

Spam protection by WP Captcha-Free