I tend to use Markdown syntax for most of my document creation needs. Then I use TextMate’s built-in Markdown support to convert to a Word document, RTF, PDF, etc… as necessary.
The one problem I have is that a lot of the so-called MultiMarkdown commands in TextMate leave me opening a file in my /tmp folder. If I forget to do a Save As… my document is lost forever. No good!
Here’s how you fix it…
I’ve added the following command to all the relevant MultiMarkdown commands:
/Developer/Tools/SetFile -a T "$DST.doc"
(Adjust as necessary changing .doc to .rtf or whatever you need, same for the $DST file path variable if that’s different in a custom command)
This uses the SetFile command (free with Apple’s developer tools) to change the converted document into a stationary pad. When you open up a stationary pad, it will create a new, untitled, document, which will prompt you to save to a location the first time you hit save.
Here’s my custom Markdown bundle to convert to a Word document:
# first figure out a name for the result
NAME="${TM_FILENAME:-untitled}"
BASENAME="${NAME%.*}"
DST="/tmp/$BASENAME"
`MultiMarkdown.pl|SmartyPants.pl >"$DST.html"`
# textutil is included with Tiger
require_cmd textutil
textutil -convert doc -extension doc "$DST.html"
`# set the file as stationary so it opens as a new doc`
`/Developer/Tools/SetFile -a T "$DST.doc"`
# Open it up in Word
open -a "Microsoft Word" "$DST.doc"
[b]Special Bonus Tip:[/b] If you choose “Auto Format” from Word’s Format menu, it will nicely convert the headers into styled headers so that you can keep your document formatted with style sheets, and will also clean up lists in the same fashion! Efficient!