Using Colored SyntaxHighlighter on WordPress

I’ve seen a number of developers using code syntaxhiglighers on their wordpress blog sites. Here are a list of plug-ins to chose from:

1: WP-Syntax
WP-Syntax provides clean syntax highlighting using GeSHi — supporting a wide range of popular languages. Wrap code blocks with <pre lang="LANGUAGE" line="1"> and </pre> where LANGUAGE is a GeSHi supported language syntax. The line attribute is optional. See sample code block below:
http://wordpress.org/extend/plugins/wp-syntax/

2: Google Syntax Highlighter for WordPress
100% client side, no server dependency, Multiple languages support, Wide browser support, Very lightweight.
http://wordpress.org/extend/plugins/google-syntax-highlighter/

2a: AS3 Syntax Highlighting (with SyntaxHighlighter)
Actionscript 3.0 add-on for Goolge SyntaxHighlighter for all the flash coders.
http://www.digitalflipbook.com/archives/2007/09/as3_syntax_high.php

3: CodeColorer
Plugin works with WordPress 1.5 and 2.0/2.1 as well. Recommended to update your WordPress to version 2.1 because it has many nice features.
http://kpumuk.info/projects/wordpress-plugins/codecolorer/

4: GeSHi – Generic Syntax Highlighter
Generic Syntax Highlighter for php. Highlight many languages, including PHP, CSS, HTML, SQL, Java and C for XHTML compliant output
http://qbnz.com/highlighter/index.php

WP-Syntax Sample Code Block

 //end colors
import com.xml.XMLData;
var myXML:XMLData;
country_id = "us";
if (_root.country_id == "us") {
	mask_can._x = mask_uk._x = Stage.width;
	var stateAbbrev = new Array("al", "ak", "as", "az", "ar", "ca", "co", "ct", "de", "dc", "fm", "fl", "ga", "gu", "hi", "id", "il", "in", "ia", "ks", "ky", "la", "me", "mh", "md", "ma", "mi", "mn", "ms", "mo", "mt", "ne", "nv", "nh", "nj", "nm", "ny", "nc", "nd", "mp", "oh", "ok", "or", "pw", "pa", "pr", "ri", "sc", "sd", "tn", "tx", "ut", "vt", "vi", "va", "wa", "wv", "wi", "wy");
	var stateNames = new Array("ALABAMA", "ALASKA", "AMERICAN SAMOA", "ARIZONA", "ARKANSAS", "CALIFORNIA", "COLORADO", "CONNECTICUT", "DELAWARE", "DC", "FEDERATED nameS OF MICRONESIA", "FLORIDA", "GEORGIA", "GUAM", "HAWAII", "IDAHO", "ILLINOIS", "INDIANA", "IOWA", "KANSAS", "KENTUCKY", "LOUISIANA", "MAINE", "MARSHALL ISLANDS", "MARYLAND", "MASSACHUSETTS", "MICHIGAN", "MINNESOTA", "MISSISSIPPI", "MISSOURI", "MONTANA", "NEBRASKA", "NEVADA", "NEW HAMPSHIRE", "NEW JERSEY", "NEW MEXICO", "NEW YORK", "NORTH CAROLINA", "NORTH DAKOTA", "NORTHERN MARIANA ISLANDS", "OHIO", "OKLAHOMA", "OREGON", "PALAU", "PENNSYLVANIA", "PUERTO RICO", "RHODE ISLAND", "SOUTH CAROLINA", "SOUTH DAKOTA", "TENNESSEE", "TEXAS", "UTAH", "VERMONT", "VIRGIN ISLANDS", "VIRGINIA", "WASHINGTON", "WEST VIRGINIA", "WISCONSIN", "WYOMING");
	instructions_mc.gotoAndStop(1);
} else if (_root.country_id == "uk") {
	mask_can._x = mask_us._x = Stage.width;
	var stateAbbrev = new Array("uk");
	var stateNames = new Array("United Kingdom");
	instructions_mc.gotoAndStop(2);
} else if (_root.country_id == "can") {
	mask_us._x = mask_uk._x = Stage.width;
	var stateAbbrev = new Array("on");
	var stateNames = new Array("Ontario");
	instructions_mc.gotoAndStop(2);
}
function setRollOver() {
	for (var i:Number = 0; i &lt; stateAbbrev.length; i++) {
		//trace("cap_name: "+stateNames[i]);
		me["" + stateAbbrev[i] + "_mc"].cap_name = stateNames[i];
		me["" + stateAbbrev[i] + "_mc"].onRollOver = rollOverMC;
		me["" + stateAbbrev[i] + "_mc"].onRollOut = rollOutMC;
		me["" + stateAbbrev[i] + "_mc"].onRelease = onReleaseMC;
		////trace(i);
	}
	fetchXML();
}
setRollOver();

Leave a Reply