Best Wordpress Plugin for Code Highlighting for ActionScript3

by troy on June 27, 2009

Getting code snippets from blogs is one of my favorite ways to get cool tricks, so much faster than going over to SVN etc. Actionscript3 is pretty similar to many languages so most of these wordpress plugins work. However in testing a few, while some make it pretty, not all make it easy for others to use the code without having to jump through hoops.

I've tried several over the years.

Getting code into the blog worked fine, getting code out was another story. In particular I had issues with quotes getting converted and linenumbers. Rather than dig and fix it, switched over to another popular one named "Wp-Syntax", that like the one from Dean also uses the GeShi for the syntax highlighting.  Since they all share the same basic syntax it was easy to switch over, each code block is wrapped in a pre tag like this, with code in between

<pre lang="actionscript3" line="1">
 YOUR CODE GOES HERE</pre>

Here's an example:

/*The following example outputs 100 random integers between 4 and 11 (inclusively):
* randRange(4, 11), works for positive and negative,
*/
public static function randomInRange(min : Number, max : Number) : Number {
	var randomNum : Number = Math.floor(Math.random() * (max - min + 1)) + min;
	return randomNum;
}

Update:

Here's a new one recommended syntaxhighlighter that uses an alternate syntax:
http://wordpress.org/extend/plugins/syntaxhighlighter/installation/

[ as3 ] YOUR CODE GOES HERE[/ as3 ]

Example:

/*The following example outputs 100 random integers between 4 and 11 (inclusively):
* randRange(4, 11), works for positive and negative,
*/
public static function randomInRange(min : Number, max : Number) : Number {
var randomNum : Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}

{ 2 comments… read them below or add one }

Og2t June 29, 2009 at 7:57 am

Hey Troy, check the http://code.google.com/p/syntaxhighlighter/ one, I am using it on my own blog (it’s not WP though but someone wrote a WP plugin I am sure).

troy June 29, 2009 at 1:54 pm

Thanks!

You’re right there is a WordPress wrapper for it, http://wordpress.org/extend/plugins/syntaxhighlighter/

I’ll try it out! hadn’t heard of it (but have seen it on other’s blogs)

Leave a Comment

Previous post:

Next post: