The Nameless Horror

Scrivener: Compiling for MultiMarkdown

As much for my own reference as anything else, here’s what you actually need to do to get regular word-processor-style text (first line indent, single return between paragraphs, all that jazz) in Scrivener compiled into proper MMD syntax, line breaks and all, because the manual (at least for 2.3) is missing a few vital points. (Note that I haven’t used images or notes, all that jazz (not even a stray link), so this isn’t everything, just the vital basics of text formatting and paragraph breaks.)

  • Select your ‘Draft’ folder or whatever contains your whole, complete, document. Go to Format > Convert > Bold and italics to MultiMarkdown Syntax and click on it. This will replace your italics with single asterisks, bolds with double. (If you don’t know what Markdown is and this is meaningless, see Daring Fireball. I use MD to write all my online stuff, including this very post, and MultiMarkdown is Fletcher Penney’s expansion of the John Gruber original. It’s a lovely way of producing properly structured documents easily using only simple syntax.)
  • While you’re doing this, you might as well use the same Convert menu item to straighten smart quotes and drop any stray double spaces you’ve missed.
  • You might notice that there’s a Format > Text > Remove All Tab Stops option to strip first line indents (which you don’t want in Markdown). Clicking on this will zero-indent all your paragraphs and (for some reason on mine at least) double-line-break them instead. Perfect for MD! Or not. Those indents are still there as tabs, and your paragraphs are not double-returned. If you compile now, you’ll see. And, if you’re like me, fume with rage. Solution: CMD+F to open the Find & Replace window. Enter Opt+Tab (that is, click in the box and press Opt/Alt+Tab) in the Find box and it will produce a tab space. Enter nothing at all in the Replace box and click Replace All. It will find all the tab characters in your document and remove them, rather than merely hiding them. Hooray!
  • In theory, you can use the same technique to double-return all your paragraphs (CMD+F, Opt+Return in ‘Find’, Opt+Return+Return in ‘Replace’, select ‘Replace All’), but this crashed Scrivener when I tried it on a 70,000 word document so I don’t recommend it. Instead, click Compile and choose MultiMarkdown in the pulldown Compile For: menu at the bottom. While you can monkey with the usual separators (I’m a quad-dash HR man myself), meta-data etc. settings, the key one you need is Replacements. Make a new replacement by clicking the plus sign. In the Replace column, click and enter (press) Opt+Return (it’ll show a blank, but that’s cool). In the With column, click and enter Opt+Return+Return (it’ll show two blanks as you hold down Opt and press Return twice, but that’s also cool). Now Compile.
  • Hey presto! Blank lines separating paragraphs, no indents, all your bold and italic text asterisked as it should be. Everything works. Plain MMD text ready to edit, copy to your blog-posting window of choice, whatever.
  • (For what it’s worth, there are a billion choices for recompiling MMD into RTF, DOC, PDF or anything else; it’s going the other way that’s the trick.)
  • (Also, I need to auto-replace chapter headers with versions between double-hash marks to render them as H2 (or your header tag of choice) under MMD, but that should be trivial.)

It’s taken me ages trawling the Scriv forums to cobble together this solution - the pressing Option and Tab/Return to enter characters you normally can’t in text boxes is vital. I’d have thought - pretty please, Scriv people - auto-parsing paragraph returns into doubles when compiling for MMD and auto-removing single tab indents would be at least tickbox options since you need these things to properly display the most elementary of text in Markdown, but apparently not.