Installing Markdown as an OS X Services Menu Item Using Automator

Posted by on Aug 4, 2010 in Geekery, Mac, tips, tutorial | 9 Comments

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.

Automator.png

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:

Screen shot 2010-08-04 at 07.56.41.png

Then I added a “Run Shell Script” action from the Action Library (I just searched for “script” to find it):

Automator 2.png

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:

Automator 3.png

…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 ~/Library/Application\ Support/MultiMarkdown/bin/MultiMarkdown.pl.)

Save the Service under whatever name you want:

Screen shot 2010-08-04 at 08.03.32.png

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:

TextEdit 2.png

And, after a couple of seconds of clicking and whirring, bingo! Shiny fresh HTML replaced the Markdown text:

Screen shot 2010-08-04 at 08.09.23.png

Verily, the ease of adding Services to OS X using Automator these days is a draggy droppy joy.

9 Comments

  1. Gone Markdown Crazy « Josh Bancroft's TinyScreenfuls.com
    September 8, 2010

    […] I added Markdown and SmartyPants as Unix Filter to TextWrangler using these instructions. I also added Markdown and SmartyPants as Mac OS X system Services using Automator, so I can use them anywhere on my Mac (in TextEdit, etc.). I’m also going to install the […]

  2. Thomas Riggs
    April 3, 2011

    Fantastic! This really makes writing in (Multi)Markdown day-to-day very compelling. I’d normally use a TextMate bundle to do the conversion before posting to TwoStopsDown, but now it’s just a keystroke.

    Also, pro tip: works in MacVim just as well as it does anywhere else in OS X.

  3. Adding “Convert Markdown to HTML” to any Text Editor on OSX | Sven Seebeck
    May 28, 2011

    […] first to convert the text to HTML, but I was looking for a simpler solution and quickly found a services tutorial which I adjusted slightly to suit my […]

  4. Michael
    June 6, 2011

    This is awesome! I also went through the same process for adding a HAML and SASS service.

  5. System-wide Markdown in your contextual menu | Subjective
    June 19, 2011

    […] All you need is the Markdown script from DaringFireball and then just follow Matt’s instructions. […]

  6. Markdown + WordPress + MarsEdit » That Not So Fresh Feeling
    September 6, 2011

    […] of google-fu, of course I stumbled on a much beter solution. Install Markdown (or MultiMarkdown), setup a service, and then type up Markdown in MarsEdit, transform it with the service, and then publish as normal […]

  7. torpdeodamning
    October 23, 2011

    Great stuff.

    Seekers of the mega-super-extra fancy might check Brett Terpstra’s pre-packaged markdown/Service-ninjitsu here:

    http://brettterpstra.com/project/markdown-service-tools/

  8. Nuovo test… | Life In Low-Fi
    April 3, 2013

    […] grazie a San Automator e soprattutto a Gothick, il risultato voluto è […]