[TxMt] Re: snippet to generate unique ID, detect end of document, and move cursor
Dr. Drang
drdrang at gmail.com
Mon Jul 26 21:59:03 UTC 2010
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
More information about the textmate
mailing list