Formatting source code when posting with MarsEdit 3

This blog is hosted on Squarespace.com and in general I would have to say I am happy with the service apart from a couple of minor issues. The first is that there is no easy way to optimise the site for viewing from the iPhone. No big deal but since this is a blog mostly about developing for the iPhone it is a shame.

The other issue is that it has been a real pain to post code examples. The Squarespace web UI provides a WYSIWYG interface but no real support for formatting code other than using a fixed-width font which looks pretty ugly. I want any Objective-C code I post to look the way Xcode intended it to look in all its syntax highlighted glory.

I have been experimenting with using Pygments, a python based syntax highlighter. I built a simple OS X Automator service that would convert a block of Objective-C code I had pasted into TextMate into nicely highlighted html code. I would then paste the block of html into Squarespace. The result was better than nothing but to be honest still fairly ugly.

Well yesterday MarsEdit 3.0 was released and it may be the solution to my problem. MarsEdit has been around for a while and is a much praised desktop blog posting tool for the Mac. I have tried MarsEdit in the past but it did not play well with Squarespace. I found that I always needed to go fix the post in the Squarespace web interface to correct formatting issues. (This seems to be a limitation with Squarespace rather than MarsEdit.)

New in MarsEdit 3.0 is the possibility to create posts using a rich text format. Even better the formatting is preserved when posting to Squarespace. The nice side-effect of this is that I can cut and paste code from Xcode directly into MarsEdit and it retains all of the formatting and syntax highlighting from Xcode.

You can see the result in yesterdays blog post on iPad Gestures. The sample code in the blog post looks identical to the code as it appears in Xcode.

MarsEdit has lots of other nice features but for me being able to easily post nicely formatted code is a must have. I am currently on a 30-day trial of MarsEdit 3 but so far I think I may be handing my $39.95 over to the red sweater guys at the end.