SyntaxHighlighter Plug-in: Posting Source Code in Wordpress (.org)
Wordpress.com added new feature that allows you to post the sourcecode on your blog in very easy way. You don’t need to do anything about manual color highlighting for your sourcecode. You don’t need to find the theme which has a stylesheet defined for PRE or CODE tag. You can just paste the sourcecode within [sourcecode language=’css’]…[/sourcecode] and specify the language of your sourcecode. How easy it is!!
using System.Data.Linq;
using System.Data.Linq.Mapping;
[Table(Name = "Customers")]
public class Customer
{
[Column]
public string CustomerID { get; set; }
[Column]
public string City { get; set; }
public override string ToString()
{
return CustomerID + "\t" + City;
}
}
static void Main(string[] args)
{
DataContext db = new DataContext(
@"Data Source=.\sqlexpress;Initial Catalog=Northwind");
db.Log = Console.Out;
var results = from c in db.GetTable<Customer>()
where c.City == "London"
select c;
foreach (var c in results)
Console.WriteLine("{0}\t{1}", c.CustomerID, c.City);
}
The most of tech bloggers including me are very happy with this new feature.
What about for self-host wordpress bloggers? Is there any plug-in for syntax highlighting?
UPDATED: Please check the updated information at the bottom of this post.. Thanks
Of course! Yeah. There are a lot of plug-ins for syntax highlighting. But if you wanna use something looks exactly like the one from wordpress.com then you may probably check-out the plug-in called SyntaxHighlighter that uses javascript syntax highlighting library which is used by wordpress.com to implement that new feature.
Where can I get “SyntaxHighlighter” plug-in?
Download from this link “http://erik.range-it.de/wordpress/plugins/syntaxhighlighter/“. (Of course! it is free.)
How to install and configure “SyntaxHighlighter” plug-in?
- Extract the zip file (“syntax.zip” for now)
- Copy all files and folders (syntax.php, [Styles] and [Scripts])
- Paste them under wordpress/wp-content/plug-ins/
- Open the browser and Go to Plug-in page (eg: http://localhost/wordpress/wp-admin/plugins.php)
- Activate the plug-in
- Go to “Options” tab in the admin panel
- (There will be new tab called “Syntax” in Options panel.) Go to this tab. You will see a lot of options for syntax highlighting as picture below.

- You can specify the languages of your sourcecode that you are going to post on your blog. For example, if all codes that you post on your blog are written C# or Javascript then check the C# and Javascript checkedboxes in this page.
- then, click “Update Options” button.
- finally, you can start posting the sourcecode on your blog.
How to post the sourcecode or How to use this plug-in?
Well. this is very simple.
- Copy the code that you wanna post and paste them within [sourcecode]…[/sourcecode]
- Specify the language of your code. (eg: [sourcecode:javascript]…[/sourcecode] )
- Done!
What is the differences between SyntaxHighlighter plug-in and the one from Wordpress.com?
Firstly, I don’t work for wordpress.com so I’m not sure how they implement this plug-in for wordpress MU. But I believe that both of them are pretty much the same since they are mainly relying on javascript syntaxhighter. I found only two differences as below while I was testing those plug-ins.
1. You can’t specify HTML, XSLT as a language in Wordpress.com.
2. You can’t disable some languages that you are not using in your blog.
Last but not least (Performance)
This link said,
SyntaxHighlighter uses regular expressions to parse the text. It’s not extremely fast, in fact, it’s pretty slow. If you are trying to highlight a few dozens lines of code, you won’t see any problems. Trying to highlight 10kb worth of text will result in JavaScript being aborted because of long execution time.
Other wordpress plug-ins for syntax highlighting
- Wp-syntax (http://wordpress.org/extend/plugins/wp-syntax)
- iG:Syntax Hiliter (http://blog.igeek.info/wp-plugins/igsyntax-hiliter/)
- Wordpress (http://wordpress.org/extend/plugins/syntaxhighlighter/)
UPDATED: I found the original plugin which is written Matt for Wordpress now. This plugin also called SyntaxHighlighter. Here is a link if you wanna download. As this plugin uses the same tag format like wordpress.com, you don’t need to change anything in your post to highlight the correct style.
January 23rd, 2008 at 1:02 am
thanks for plugin information.
October 8th, 2008 at 1:58 pm
hi,
can you help me to find a way to remove this white margins between lines?
http://pix.academ.org/img/2008/10/09/c6ffbe1756a7485af1ad538702f7ce43
December 10th, 2008 at 6:04 am
Thanks! gut text
December 15th, 2008 at 5:18 pm
Hi!
I’ve found your article to be very useful, though the information is not rather new.
I’m your permanent reader now!
p.s. BTW, what happened to your site template? Or is it just my browser? :)
http://samsungln46a650review.tumblr.com/
December 16th, 2008 at 3:01 pm
Very usefull post, i think i will use it.
Thanks.
December 17th, 2008 at 10:23 am
Hello I’m new here
And it looks like a great forum, so just wanted to say hello! :):):)
And looking forward to participating.
Going on vacation for a few days, so i’ll be back
December 18th, 2008 at 6:15 pm
Hi all!
As newly registered user i just want to say hi to everyone else who uses this bbs :>
January 9th, 2009 at 3:28 pm
Greetings I’m new here
And it looks like a good forum, so just wanted to say hello! :):):)
And looking forward to participating.
January 21st, 2009 at 5:49 pm
Nothing seems to be easier than seeing someone whom you can help but not helping.
I suggest we start giving it a try. Give love to the ones that need it.
God will appreciate it.
February 18th, 2009 at 5:13 am
Hello… ;)
April 23rd, 2009 at 5:02 pm
I’m the only one in this world. Can please someone join me in this life? Or maybe death…
May 20th, 2009 at 12:09 pm
Hiya all of youz!..
How are yaz doing?
June 11th, 2009 at 4:04 pm
Greetings
I’ve been passive on this forum for a while now, so here goes my first post! a great site I’ve found for Free Mobile Applications etc. is Esnips.com I’ve found everything on my list…
let me know what you think!, Hope this helps ;-)
Cheers
August 13th, 2009 at 4:25 pm
This looks cool so far, what’s up people?
If it’s not just all bots here, let me know. I’m looking to network
Oh, and yes I’m a real person LOL.
Later,
September 16th, 2009 at 9:40 am
Hi there, I am getting a large number of students that can’t access the internet. When they log on and open IE they don’t get the default web page or a log in screen. It appears to be random, I have tried setting up new user accounts but this also appeasrs to be hit and miss on whether they get access.
Any ideas?
Cheers
Alan
October 15th, 2009 at 1:49 pm
Just wanted to say hello all. This is my first post.
I came to learn alot here.