Okay perfect. The way Scrivener works with MMD is all about pipes, both STDIN and STDOUT, so all you need is a script that takes the compiled plain-text, runs a few regexps to clean out the punctuation, and spits the result back out so that Scrivener can dump the final file in the specified location.
The first thing you need to do is download a fresh copy of MultiMarkdown and install it into your [b]~/Library/Application Support[/b]
folder. Scrivener is set up to use that folder instead of its internal copy, if one exists, and this will make it easier for you to edit the guts without poking around in Scrivener.app.
Once you unzip the distribution, the folder you want to navigate to within it is [b]bin[/b]
, which contains all of the control scripts that handle the MMD system. Scrivener just calls one of these, depending on the compile format type, and as said pipes stuff in and gathers the results out. Thus all we need to do is choose one of the controls scripts and subvert it into something else entirely.
Any of them are fine, especially if you have no intention of using MMD in the future. If you do, then I’d pick RTF or LaTeX, depending on whether or not you’d ever intend to use either of those. So depending on that selection, you want to create a backup of [b]mmd2LaTeX.pl[/b]
or [b]multimarkdown2RTF.pl[/b]
, and then replace the contents with something very simple like:
[code]#!/usr/bin/env perl
$data = “Testing MMD over-ride:\n\n”;
$data .= <>;
Do stuff to $data
print $data;[/code]
Now, if you compile your draft to MMD->LaTeX (or RTF) and get your manuscript compiled out completely, with the test line at the very top, you know you did everything right, and now all you have to do is build and test your data manipulation code.
That’s it! Once you have that set up, you should be able to compile straight out of Scrivener and get an optimised draft for Nano.
One thing you may want to address in your data manipulation is to remove hashmarks. If you export titles, since Scrivener isn’t aware of the fact that you aren’t actually using MMD, it will wrap the titles in a number of hashmarks equal to its outline depth. So you’ll need a regexp that strips those out most likely as they might otherwise inflate the word count. Titles look like this in MMD:
[code]# Level one #
Level two header
Level three header ###[/code]
Build the regexp to handle any number of hashmarks on the front and back.
s/^#+\s(.+)\s#+$/\1/
Ought to do the trick.
⠂─────── ⟢⟡⟣ ─────── ⠂
The only caveat with this trick is that Scrivener 1.x will force extensions on you. You’ll have .tex or .rtf files even if they are actually .txt files. Just fix it in the Finder and you’ll be okay. Though, by the time you’ll be doing real compiles in late November you’ll be using 2.0, which lets you supply your own extensions easily.