Saturday, 22 November 2008

Intermission: Posting code on Blogger

The series I'm posting on circular buffers in C++ is a bit of a personal experiment in article writing; attempting to form an article on-line in pieces that can eventually be assembled into a cohesive whole.

Thanks for the feedback you're giving me, in comments and by email. The encouragement is great.

The experience has been an interesting one so far. In fact, it's also been a quite frustrating one. The Blogger editor is supremely unhelpful when you try to enter preformatted text (like C++ code).
  • Code with angle brackets (e.g. < and >) is hard to get into Blogger without accidental butchering during editing or display, since you fall into all sorts of complex HTML problems.
  • The Blogger editor continually reformats my pre-formatted code, stripping spaces, inserting spaces, realigning things. Every time you open the editor to fix one mistake, it breaks everything you fixed last time. Very frustrating.
  • The editor window is far too small for anything except the smallest pieces of writing.
  • I've attempted using external blog editing software, Quama to sidestep these issues. It's a beta version, and so somewhat buggy. It also has it's own ideas of how to butcher and reformat my code.
  • The Blogger layout themes don't really help to make code readable at all.
If anyone has any cunning solutions to this problem, I would really love to hear them! Otherwise, I'll soldier on fiddling with code by hand and losing what's left of my hair. Please do point out layout issues to me, and I'll do my best to fix them.

4 comments:

Unknown said...

I'm using this:

http://code.google.com/p/syntaxhighlighter/

You can integrate it into your blogger HTML like this:

http://paste.rikkus.info/9

I uploaded the necessary resources to googlepages, as you can see from my example.

HTH!

Unknown said...

There's another decent-ish option: If you're using Firefox, you can use the 'It's all text' extension and use your favourite editor to author your posts - and use its inbuilt transform-to-highlighted-html function on the code parts... I've done this with gvim and it's not the worst idea ever.

Unknown said...

In case you're not sick of advice: The 'Simple II' layout (part of the standard list of blogger templates) is pretty good when you're showing code - it's nice and wide.

R said...

Another nice out-of-browser option:

http://pygments.org/