Syntax highlighting – Posting Source Code on WordPress

Crikey! I’ve finally found a good way to get syntax highlighting on my code posts on WordPress! Here is the WordPress article on the tag to use for syntax highlighting, thanks WP!

To summarize, to outline your code include this around it:

[sourcecode language=”css”]
your code here
[/sourcecode]

where language can be many things (check the link for a full list), these are some:
sql, csharp, vb, xml, javascript, java, html, css, powershell

This code highlighter is pretty neat, it’s client side JavaScript that does the highlighting. Written by Alex Gorbatchev, available on his site here. I have noticed a couple bugs in the sql parser, but overall I quite like it.

Advertisements
  1. #1 by eduardo spotorno on November 11, 2011 - 7:56 pm

    this also works with user replies?

    
    <tag>this is my tag</tag>
    
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: