WordPress Plugin for Google Syntax Highlighter
I am a big fan of the source code highlighter used by the Waffle project. Michael Ward recommended it for me to use when I set my blog up a few weeks ago.

The highlighter itself is simple to use on its own - it’s just a javascript include but I had been using another code highlighter which had a WordPress plugin that made it’s use a snap.
I figured it wouldn’t be too hard to create a plugin for the syntax highlighter (which had larger language support including ruby which I needed) and so I did. The plugin is being hosted by WordPress and I encourage you all to take a look and use in your own blogs.
August 22nd, 2007 at 7:09 pm
Thanks Peter - this is gold!
October 9th, 2007 at 6:52 pm
This doesn’t seem to work with 2.3. I’ve installed, activated, and input even the test syntax you have posted, and, it just doesn’t do anything… at all.
Looked awesome too 
October 18th, 2007 at 7:00 am
hi,
nice plugin and it works with 2.3,
but: your plugin writes class=”javascript” in the script tags. this is wrong and produces an xhtml validation error.
see: http://www.validome.org/validate/?uri=http://www.peterryan.net
it would be better if you use the attribute type instead of class for script tags.
July 20th, 2008 at 8:22 pm
[…] | Author: Peter Ryan Coloring: #4 of 8 Ease of Install/Use: #7 of 8 Line Numbers: Optional PRE or CODE: PRE Other […]
July 23rd, 2008 at 5:50 pm
Very nice plugin !
I’ve made some small changes to your HTML markup to get it W3C valid. You can get the modified version here : http://lapin-blanc.net/downloads/google_syntax_highlighter.phps
With this patch, only the plugin markup will be valid, the core JS code always require to use which is invalid.
Please include my changes in trunk
July 24th, 2008 at 1:14 am
Hi Peter,
I use it on my site and it works very nice. I also made few changes to load only brushes that are needed and move load of JavaScript files to the top of HTML page.
Thank you for your plugin!
September 7th, 2008 at 8:53 pm
Thanks a lot.
October 29th, 2008 at 9:05 am
Thanks a lot for this plugin.
One request though. Brush for bash shell script would be really cool feature.
October 29th, 2008 at 12:08 pm
I’ve added bash brush to the plugin. You can get the extended version of the plugin from here
http://tech.xlab.si/wp-content/uploads/google-syntax-highlighter-with_bash-151.zip
Thanks a lot to bboy.mr.freeze.
November 6th, 2008 at 10:34 pm
The plugin crack’s the html validation !
In the function hooked up to the footer you should be use this
November 13th, 2008 at 2:38 pm
FYI…
Your example on the installation page of your plugin page has a typo.
http://wordpress.org/extend/plugins/google-syntax-highlighter/installation/
It is missing the equal sign between class and “ruby”
December 17th, 2008 at 8:41 pm
Hi Peter,
I vote for the HTML W3C bug discovered by various people earlier in your comments. Please change the class=”javascript” to type=”text/javascript” in your script declarations and republish the plugin.
Anyway, thank you for the plugin,
Simon
February 3rd, 2009 at 5:42 pm
[…] After looking at a few of the recent smashing magazine posts and specifically 10 killer wordpress hacks I decided it was time to look into Wordpress Syntax Highligher Plugins. A quick Tweet later and I had a fantastic round-up from Chris Cagle who runs a small web company. Amazing list ad to have all the work done and a test below to prove it works. I went with the solution from Peter Ryan of Google. […]
February 10th, 2009 at 8:36 pm
I found, by default, the rendered code is padded by wordpress, creating gaps between the lines. I found adding the entry below to the main style.css page, it resolved the issue. There might be a way to do this from the plugin’s css, but this won’t affect anything else so it should be ok.
html > body .entry .dp-highlighter li {
margin:0;
}
July 6th, 2009 at 12:40 pm
2sdkUI Nice post. Thanks for sharing. You can watch live steraming soccer tv in my blog. Thanks,
July 6th, 2009 at 12:40 pm
Cool Info, practical.. lol,
August 23rd, 2009 at 3:35 pm
Doesnt work anymore =(
Are you going to upgrade your script? Maybe i could also do this job and take over the project
September 11th, 2009 at 7:09 am
thanks for useful post.
November 10th, 2009 at 11:22 am
This plugin seems pretty bust now, wordpress by default strips the name and class attributes from pre tags meaning without overriding some defaults with a custom plugin or a hack it’s pretty useless.
November 20th, 2009 at 3:06 pm
plugin works just fine for me, I think the “strip” part your talking about is because you are trying to use xml tags under the “visual” editer and not the “html” part. This will ofcourse automatically format and strip out the tag. Also you may need to diable the auto fix xhtml option in the general tab.
I did however find a bug in the css on line 113, the attribute “text-align1″ should be text-align me tinks. Ive also added several custom languages to the highlighter syntax libs, you can check out http://superscriptz.com to see the script in working action.
December 18th, 2009 at 6:03 pm
hello i love to move and im looking for a good website to learn how to break dance
December 26th, 2009 at 10:52 pm
the plugin works fine for firefox and google chorme, but it doesn’t work on IE8.
WordPress2.9+plugin1.5.1
Error info:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
time: Sun, 27 Dec 2009 03:33:21 UTC
Message: ‘this.regexList[…].regex’ is null or not an object
Row: 173
character: 1
code: 0
URI: ^/wp-content/plugins/google-syntax-highlighter/Scripts/shCore.js
January 7th, 2010 at 12:56 am
Thank you for your plugin!
January 22nd, 2010 at 5:58 am
Love this post! Thanks for this. I’ll be sure to come back again. P.S: I’ve bookmark your site as well
February 7th, 2010 at 4:43 am
[…] Plugins. Sucht man auf Wordpress.org nach “syntax” spuckt es WP-Syntax Colorizer, Google Syntax Highlighter for WordPress, Easy Google Syntax Highlighter und Syntax Highlighter and Code Colorizer for Wordpress […]