I love me some Markdown. If I’m writing it on my iPhone/iPad, it’s in Elements. But on the Mac, I like Byword. It’s simple, effective and visually striking. And while it does have a nicely done preview mode, you can’t view it concurrently with the marked up document. That’s mildly annoying.
Enter Marked by the always awesome Brett Terpstra. Marked is an application that lets you preview what a Markdown file will look like when it’s all prettified (amongst other things like exporting the html or making a PDF). So problem solved, right? Just open the document for writing in Byword and previewing in Marked and I’m done. Yes, well, mostly. It’s not quite as streamlined as I’d like it be.
The standard way to view a document in Marked is to either
drag the document’s icon (from the Finder or, if it’s open in an editor, the title bar) to Marked’s icon in the Dock or
launch Marked and do a File → Open.
This is probably fine if I’m going to be working on an existing document and set everything up before getting to work. But if I’m in the middle of a furious writing spree on a new document, I don’t want to take my hands off the keyboard. And thanks to the magic of a stupidly simple AppleScript and Red Sweater’s FastScripts I don’t have to.
So without further ado, here’s the script:
tell application “Byword”
set theDocument to file of document of window 1
end tell
tell application “Marked”
open theDocument
end tell
Stupidly simple. I just saved the script as ~/Library/Scripts/Applications/Byword/Open in Marked.scpt and set a keyboard shortcut in FastScripts. Now when I’m in the middle of writing, I just hit ⌘S to save the document (otherwise Marked has no file to open) then ⌘⇧M to activate the script and I’m all set.
Update: The folks behind Byword released a css style sheet specifically for Marked at almost the exact time I posted this. Nifty.
Update 19 Sept 2011: Brett has released the Marked Bonus Pack. It probably does a lot better of a job than my silly little script.