I just had a quick look around the web for ways to install Markdown translation as a Service (i.e. available from the Services menu) on my Mac. Most of the hits I got seemed to be quite old, and involved hacking about with an existing service for another text converter.
So, I experimented. And the good news is that since Snow Leopard came out, with its improvements to the Services menu and Automator support, adding Markdown conversion to the Services menu yourself is an absolute doddle. I took a guess and what I did worked first time.
First, fire up Automator. Choose “Service” as the template you want to use.
I chose the default options for the Service, except I checked the “Replaces selected text” option, so the new Markdown format text would replace whatever text I had highlighted:
Then I added a “Run Shell Script” action from the Action Library (I just searched for “script” to find it):
Finally, I added the path to Markdown.pl (obviously, you have to have a working Markdown installation in place — see Gruber’s original Markdown article if you’ve not, and come back when you’re done.) On my system, I shoved Markdown.pl in
/usr/local/bin. Just shove the path to wherever your Markdown is in the Run Shell Script action body:
…and you’re done, really!
(This also works just fine with Fletcher Penney’s MultiMarkdown. If you’ve used the MultiMarkdown installer, you’ll probably find the MultiMarkdown script you need is
~/Library/Application Support/MultiMarkdown/bin/MultiMarkdown.pl Bear in mind you’ll need to escape spaces in the path, though, so the final result will probably be
Save the Service under whatever name you want:
And you’re good to go. To experiment, I fired up TextEdit and typed in some Markdown, then chose my shiny new “Markdown” option from the right‐click menu:
And, after a couple of seconds of clicking and whirring, bingo! Shiny fresh HTML replaced the Markdown text:
Verily, the ease of adding Services to OS X using Automator these days is a draggy droppy joy.