I recently mentioned that I am currently trialling TextMate, as a possible alternative to Bare Bones Software’s eminently capable BBEdit.
Here’s one of the issues I initially had with Markdown in Textmate, and how I solved it.
Not such a SmartyPants?
Markdown has a good friend called SmartyPants that play very nicely together when installed at the same time. If Markdown was the alpha male (doing the hard work), then SmartyPants would be the woman with the incredible attention to detail. SmartyPants takes care of things like correct “quotes” and dashes—like that.
Unfortunately the default behaviour of SmartyPants has no short hand for an en-dash (–): it renders two consecutive hyphens -- as an em-dash. To change this behaviour to the LaTeX-like --- for an em- and -- for an en-dash, SmartyPants has a built-in switch, right there in the script. All you need to do is find the line, near the top of SmartyPants.pl, that looks like this
my $smartypants_attr = "1";
and change the 1 to a 2.
What’s the problem then?
This was fine to do in BBEdit, because Dan Gruber’s installation instructions very clearly indicate where the SmartyPants script is kept. I struggled to find mention of its location in TextMate anywhere on the web (and this is a problem only because it is installed by default), and finally managed to turn it up by using a spotlight search from within the TextMate.app package. All you need to do is browse to
<your Applications directory>/TextMate.app/
Contents/SharedSupport/Support/bin/
and edit the SmartyPants.pl file located in there, using your favourite text editor.
There are two ways to do this in the Finder:
- Right-click on TextMate.app and select “Show Package Contents” from the context menu, or
- Select Go -> Go To Folder… (or press Shift-Cmd-G) and type the path above, making sure to insert the location of TextMate.app on your computer.
So there you have it—robust support for em- and en-dashes, when using Markdown with SmartyPants in TextMate.
—Sharpy
One Trackback
[...] just another WordPress weblog « Unable to delete Header or Body styles in Pages ’09 Changing SmartyPants’ default behavour in TextMate [...]