With help from Tobias O’Leary, the Markdown Service Tools can finally do in-place conversion from (Multi)Markdown to RTF. The primary reason for wanting this was to allow people to write Markdown directly in Mail.app, then convert it immediately before sending. Put a shortcut key on it and it’s a snap.
In order to demonstrate how exciting this is, I have made you a video.
md - Convert - MultiMarkdown to RTF is now included in the Markdown Service Tools. Please read on for some additional information and requirements.
The Service works in any Cocoa text field that handles Rich Text. If you can change your font weight, size and color in the field, you’re in the right place.
A couple of notes:
This service requires that the MultiMarkdown binary be installed at
You can do this two ways:
- Download the installer (latest version of both the Mac and Support-Mac archives), unzip and run them.
- If you use homebrew, just run
brew install multimarkdown.
Images referenced in your Markdown will disappear. Due to the way RTF handles image attachments, including them is not possible.
The default style (Swiss from Marked) is stored in
~/Library/Application Support/MarkdownServiceTools/styles/rtfstyle.txt (created the first time you run the service). This file can be edited if desired, but should remain a single line starting with “XHTML Header: “ and contain a full
<style></style> declaration. Embedded fonts don’t work, and there are a lot of elements lost when converting, so it takes some experimentation.
You can boil your CSS down to a single line using any of the various compression tools, or use a web service.
How it works
The MultiMarkdown to RTF works by converting the selected Markdown using the
multimarkdown binary and passing the output HTML to the OS X utility
textutil command converts the raw HTML into RTF data in a temporary file, which is then read into the RTF clipboard and pasted back to the file. That’s the secret sauce: when
pbcopy -Prefer rtf is passed input on STDIN, it fails to create the clipboard RTF properly. Passing it out to a temp file and reading it back in allows it to function properly.
If you open up the
workflow file in Automator, you can see the sausage factory floor.
The original contents of the clipboard are preserved and restored after the Service runs.
Download directly below, or see the project page for more details on installation and configuration.
Markdown Service Tools v2.12
The Markdown Service Tools are a collection of OS X Services designed to make creating Markdown-formatted text that much easier. Services work in any OS X Cocoa based application.
Updated Thu Jan 09 2014.