BotanJs-SyntaxHighlighter

This is a port from SyntaxHighlighter for BotanJs framework.

Links

Demo

This is an example Bootstrapping SyntaxHighlighter dynamically if the class is present
(function(){
	var ns = __namespace( "Astro.Bootstrap" );
	var debug = __import( "System.Debug" );
	
	// __import( "Dandelion.CSSReset" ); CSS_RESERVATION
	// __import( "Dandelion.CSSAnimations" ); CSS_RESERVATION

	var infs = [];

	// Init Helper, body onload
	var regInitFunc = function( f ) { infs[ infs.length ] = f; };

	var inited = false;
	var consoleExists = false;
	var CConsole = "Components.Console";

	var SyntaxHighlighter = "Libraries.SyntaxHighlighter";

	var init = function()
	{
		if( inited ) return;
		inited = true;

		if( consoleExists )
		{
			// The + is to prevent resolver resolving this class
			// since this is optional
			new ( __import( CConsole ) );
		}

		var l = infs.length;
		debug.Info( "[Astro.Blog] init(" + l + ")" );
		for( var i = 0; i < l; i ++ )
		{
			infs[i]();
		}
	};

	/*{{{ Class Catching */
	BotanJS.addEventListener( "NS_EXPORT", function( e )
	{
		switch( e.data.name )
		{
			case CConsole:
				consoleExists = true;
			break;
			case SyntaxHighlighter:
                debug.Info( "[SyntaxHighlighter] Initializing" );

                /** @type {Libraries.SyntaxHighlighter} */
                var synt = __import( SyntaxHighlighter );
                synt.defaults["toolbar"] = false;
                synt.defaults["quick-code"] = false;
                synt.highlight();
			break;
		}
	});

	try {
		__import( CConsole );
		consoleExists = true;
	} catch( e ) { };
	/* End Console Catching }}}*/

	ns[ NS_EXPORT ]( EX_FUNC, "init", init );
	ns[ NS_EXPORT ]( EX_FUNC, "regInit", regInitFunc )
})();