On 26 July 2010 22:59, Dr. Drang drdrang@gmail.com wrote:
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.
I had actually successfully adapted the text insertion, but was doing something stupid with the regex. I don't use the reference link functionality often, so it's not too bad in terms of the mess. I'm finding that there's a blank line required between each footnote for some reason, but that's not a problem for me, and I've added a . "\n" . after the $text var, and it's behaving fine. Thanks again for the help.
-- Dr. Drang
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate