Sunday, August 26, 2007

Markdown Scripts for MarsEdit  

I've created a few AppleScripts for MarsEdit to simplify the process of using Markdown to post to any weblog (like, say, Blogger) that doesn't natively support it.

Translate Markdown to HTML

This script takes text written in Markdown syntax and translates it into HTML. Extraneous line breaks are eliminated, because many blog hosts like to translate them into <br /> tags.

This works particularly well because MarsEdit has native support for previewing content written in Markdown. I normally use the Markdown preview mode while composing a post, then convert it to HTML just before posting.

But wait, you say: what if you need to edit a post?

No problem, says me. Then you use the other script.

Translate HTML to Markdown

This script uses Aaron Swartz's html2text to translate the post from HTML back into Markdown. It works on any HTML post, not just ones that you've created with the other script. Then you're free to edit the post, convert it back to HTML, and repost it.

Updated: Now with Unicode support

Update, Oct 4 2007: MarsEdit's author, Daniel Jalkut, alerted me to the fact that these scripts had problems with non-Roman text and offered a fix. Sure enough, I'd forgotten that AppleScript needs special care to do the right thing and handle text files as UTF-8. I've updated them appropriately.

Get them now!

Interested? Download the scripts now!

MarsEdit Markdown Scripts

5 comments:

  • Drew Thaler said...

    By the way, the scripts are public domain. I know a thing or two about AppleScript so they're probably not bad reference source if you're trying to do something similar.

  • pjmm said...

    Thanks very much for making the scripts public: they're really helpful both in use (I'm using blogger) and as learning tools for Applescript (using which I always seem to get 98% of the way there in 2% of the time, and end up pulling my hair out while spending the other 98% of the time getting the other 2% of the script to behave as desired).

    Best wishes,
    Paul

  • Derek said...

    Having a helluva time finding these scripts... Seems like multisolar.com doesn't exist any more.

    Little help?

  • Drew Thaler said...

    Sorry, multisolar.com suffered a hardware crash last weekend. It'll be back up within a few days.

    In the meantime, you can get the 1.0.3 scripts directly from here.

  • Josh Renaud said...

    That mac.com link isn't working either...