I'm finally getting around to writing a blog post and would like to include some c# code.

Is there a plugin or something available for me to use?

If so, could someone provide a link showing me how to use it to format my code?

If not, could someone please install a plugin for formatting?



I really like the way code gets formatted in SE, well, it would be nice to have colors without relying on a c# tag but anyway ...

public void Kalkulate(IDisplayTable dispTable, string targetField, bool bJustSelected)
      object[] args = { dispTable, targetField, bJustSelected };

I'd like the same capability in wordpress, but when I try the <code> tags like this: enter image description here

... I see this in the preview of the blog post:

enter image description here

Update 2

When I enter code like this with var lined up with foreach: enter image description here

The preview looks like this, with the indentation offset:

enter image description here

Is there some way I can correct this?

Update 3

If I put code in and format it I see this ... enter image description here

If I click on the Visual tab, then click on the HTML tag, my source code gets collapsed into a single line, like this: enter image description here

  • Try changing the <code> tags to <pre> Commented Oct 10, 2011 at 17:56
  • 3
    If code is something that will be posted often, we could look in to a plugin that does prettify...I'd imagine there is one. In general, I'm absolutely happy to install a good plugin if the community has a need for it and it would be beneficial. Feature requests for the blogs can be posted here just as requests for the main site. Commented Oct 10, 2011 at 23:33
  • @RebeccaChernoff I've never used it, but Alex Gorbatchev's Syntax Highlighterseems to be very popular. Commented Oct 10, 2011 at 23:43
  • There's really no reason we can't use the same syntax highlighter that SO (and GIS) use. I suspect it would be more useful though if we pulled in one of the plugins that let you demarcate code snippets within the normal editor. Or... Let you just write the whole thing in Markdown.
    – Shog9
    Commented Oct 10, 2011 at 23:48

1 Answer 1


The blog editor supports the <pre> tag. Just wrap your code in <pre> and </pre> and the formatting will be preserved.

Note that if your code includes HTML reserved characters (especially < or >) you'll have to manually replace them with the proper entities (&lt; for <, &gt; for >, etc.)

  • please see the update to the question. Thanks! Commented Oct 10, 2011 at 17:39
  • Revised to reference correct tag, @Kirk
    – Shog9
    Commented Oct 10, 2011 at 17:56
  • Ah, yes, now I remember. I guess I've just gotten spoiled using SE's code tags. Thanks! Commented Oct 10, 2011 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .