Testing the syntax highlighter

So, I added this awesome plugin called SyntaxHighlighter Evolved that converts code into a pretty look on the blog. The reason for using this is obvious to any developer. It’s a real pain in the butt to convert code so that it will display in HTML. And you want to display code every now and then to show off your geek fu or just to complain about some code that was bugging you.

Let’s see if my new buttons work. Basically, I am using WP-Quicktag to easily add QuickTags to a post. For the SyntaxHighlighter I decided to add two QuickTag buttons. One for ActionScript 3 and one for JavaScript, since they are the code types I use most in my custom development. The buttons place the QuickTags around the text I want to show as code.

This is an ActionScript 3 code example


:

public function initApp():void
        {
			oneMinuteTimer.addEventListener(TimerEvent.TIMER, oneMinuteTick);
			oneMinuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, resetOneMinute);
			oneMinuteTimer.start();

			twoMinuteTimer.addEventListener(TimerEvent.TIMER, twoMinuteTick);
			twoMinuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, resetTwoMinute);
			twoMinuteTimer.start();

			fiveMinuteTimer.addEventListener(TimerEvent.TIMER, fiveMinuteTick);
			fiveMinuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, resetFiveMinute);
			fiveMinuteTimer.start()
        }

And this is a JavaScript code example


:

function findPlayListItem(fileTitle) {
		var outItemId = 0;

		playlist = player.getPlaylist();
		if(playlist) {
			var thisTitle = '';
			for(var listItem in playlist) {
				thisTitle = playlist[listItem].title;
				if(thisTitle == fileTitle) {
					outItemId = listItem;
				}
			}
		}
		return outItemId;
	}

The simplicity of adding these little blocks around the code to save a ton of time is one of the great things about WordPress. Now if I can only find a quick way to update any old posts with code in it.

About DeanLogic
Dean has been playing around with programming ever since his family got an IBM PC back in the early 80's. Things have changed since BASICA and Dean has dabbled in HTML, JavaScript, Action Script, Flex, Flash, PHP, C#, C++, J2ME and SQL. On this site Dean likes to share his adventures in coding. And since programming isn't enough of a time killer, Dean has also picked up the hobby of short film creation.

About DeanLogic

Dean has been playing around with programming ever since his family got an IBM PC back in the early 80's. Things have changed since BASICA and Dean has dabbled in HTML, JavaScript, Action Script, Flex, Flash, PHP, C#, C++, J2ME and SQL. On this site Dean likes to share his adventures in coding. And since programming isn't enough of a time killer, Dean has also picked up the hobby of short film creation.