Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a (free) blog engine (WordPress...) that handles sections of code well. That is, I could just markup a portion of my entry as code and it would indent/format appropriately, much like Server Fault does right below:

  static void Build()
share|improve this question

migrated from Jul 29 '09 at 0:36

This question came from our site for system and network administrators.

I closed that one, so leave this one be ;-) – Ivo Flipse Mar 12 '10 at 9:32
up vote 7 down vote accepted

WordPress uses plugins which are very easy to install to handle this. I chose SyntaxHighlighter for my blog because it was easy to use, supported the languages I was after, and worked the best. You can go to my profile for a link to my blog to see some examples.

This link compares a bunch of them, some of them have themes, etc., one of them should work for you. You usually just use some sort of tag in your post like: [sourcecode lang=perl] print foo [/sourcecode] and the plugin takes care of the rest.

share|improve this answer

Prettify is used by Stack Overflow and it works very well. You just include it into your blog template and every <code> section gets highlighted automagically.

share|improve this answer

You could use SyntaxHighlighter.

SyntaxHighlighter is here to help a developer/coder to post code snippets online with ease and have it look pretty. It's 100% Java Script based and it doesn't care what you have on your server.

enter image description here

share|improve this answer

Normally this sort of thing is added to a blogging engine through including JS and setting up CSS in your posts. It's generally trivial to add to any flexible engine when done this way. Like with the google syntax highlighter.

share|improve this answer

I use GeSHi under Drupal... but it is a general PHP library for code highlighting, so there may be a plugin for Wordpress that uses it too if you prefer to use Wordpress (definitely simpler for a blog).

share|improve this answer

You also have the option of converting your code directly into colored/highlighted HTML.

Check out Pygments. You enter the code. It gives you the highlighted syntax.

It is a generic syntax highlighter for general use in all kinds of software such as forum systems, wikis or other applications that need to prettify source code. Highlights are:

  • a wide range of common languages and markup formats is supported

  • special attention is paid to details that increase highlighting quality

  • support for new languages and formats are added easily; most languages use a simple regex-based lexing mechanism

  • a number of output formats is available, among them HTML, RTF, LaTeX and ANSI sequences

  • it is usable as a command-line tool and as a library

  • ... and it highlights even Brainf*ck!

share|improve this answer

Calepin is a static blog publisher that supports syntax highlighting out of the box.

share|improve this answer
Please consider expanding your answer by adding some excerpt how the referenced program handles code highlighting. This will improve the quality of your answer. – bytebuster Nov 13 '12 at 18:02

You must log in to answer this question.

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