Feeds:
Posts
Comments

Archive for March, 2010

Format source code on WordPress

Blog is moving! You should check this post out on kevinpelgrims.com

I had a few people asking me how I managed to format the source code for my PowerShell posts, so here’s a short explanation.
Just type (or paste) your post and when it’s time to insert the source code, switch to HTML view.

There you can insert these tags:

[sourcecode language="csharp"]
somecode
[/sourcecode]

And it will come out like this:

  if(formatting)
  {
    return "Yay!";
  }

Yes, that’s all there is to it.

There are actually quite a few languages that are supported. You can see the full list and an explanation on some extra parameters on this official WordPress page: http://en.support.wordpress.com/code/posting-source-code/

Read Full Post »