WordPress (poor) support for indented code segments

I was trying to reply to a comment on one of my own posts this evening and wanted to include some indented code snippets in the reply. I duly surrounded said snippets with the code tag (which is fairly standard practice in most blogs/forums I contribute to), only to find that the indentation was not displayed when the published reply was viewed in a browser.

I found the answer here in the form of the <pre> tag. This isn’t one of the available tags in the WordPress authoring panel but does the trick very nicely, as you will see from the samples below.

Here is an example of some indented code that uses the code tag:

public void getString()
{
if (null == str)
return "";
else
return str;
}

Here is the same code with the <pre> tag:

public void getString()
{
  if (null == str)
    return "";
  else
    return str;
}

Upgrade to WordPress 2.6.2 completed

I haven’t been posting that much recently but hope to remedy that in the days and weeks ahead. Hopefully, now that I have (finally) completed by Masters Degree, I will have a little more time to post some new articles.

In the mean time, I took the time to update my blogging software to WordPress 2.6.2 this evening, so if you notice anything unusual, be sure to let me know.