Codestories

November 3, 2009

Posting source code in wordpress

Filed under: Programming — Tags: , , — Carlos @ 10:28 pm

At the beginning it was a big deal for me, i want my own blog about programming, then, i’ll need to post several code blocks, but, i don’t knew how to do it…

Finding a little bit on the internet y found out that wordpress.com implements SyntaxHighlighter (http://alexgorbatchev.com/wiki/SyntaxHighlighter)

blablabla, lets talk about what you really want to hear…

HOW POST SOURCE CODE IN YOUR WORDPRESS.COM BLOG?
It’s not a big deal…
Just wrap your code between

[sourcecode language="language"]

your code here

[/sourcecode]

tags, and “language” could be one of the next supported languages

  • bash
  • cpp
  • csharp
  • css
  • delphi
  • html
  • java
  • jscript
  • php
  • python
  • ruby
  • shell
  • sql
  • vb
  • xml

Sample

The input
[sourcecode language="csharp"]
private void ShowRates(DataClassesDataContext bd)
{
var myTable = from table
where table.deleted = false
orderby table.name
select table;
myGrid.DataSource = myTable;
myGrid.DataBind();
}
[/sourcecode]
will produce

private void ShowRates(DataClassesDataContext bd)
{
 var myTable = from table
 where table.deleted = false
 orderby table.name
 select table;
 myGrid.DataSource = myTable;
 myGrid.DataBind();
}

Easy, isn’t?

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.