Let me make two more changes to that script. The footnote snippet clearly shouldn't have the beginning of a URL as the default text, and there has to be a blank line after the footnote.
#!/usr/bin/perl use List::Util qw(max);
$text = $ENV{'TM_SELECTED_TEXT'};
# Get the highest-numbered reference. @nums = $text =~ /^[^(\d+)]: /mg; $n = max(@nums) + 1;
# Escape special characters. $text =~ s/([$\`])/\$1/g;
# Insert the snippet. print '[^${1:' . $n . '}]$0'. $text . '[^$1]: ${2:Footnote}' . "\n\n";
MultiMarkdown seems to have no trouble with mixing footnotes and reference links down at the bottom of the file, but it sure does make a mess.
-- Dr. Drang