This is getting awfully close to a general footnoting tool. If you remove the link formatting for description, you are pretty much there. That would be a useful (different) add-on. As it is, I like this one for its intended purpose. I'm using the ruby version, mostly because I did something dumb in the original install and tried ruby to see if that worked. It did, so I left it alone -- using ruby.
On 2/28/06, Fred B. fredb7@starflam.com wrote:
On 28 Feb 2006, at 17:42, Dr. Drang wrote:
Clever! And if I'm reading your code correctly, you're updating from the last number but still allowing the user to override, which is nice.
Yes, because I sometimes use something else than numbers like e.g. [mail]. And if it's the first numerical reference, it proposes "1".
BTW, the second reference I make to #{n} was not necessary, I removed it.
#!/usr/bin/env ruby
str = STDIN.read n = str.scan( %r{.*[(\d+)]: }m ).to_s.to_i + 1 print "[${1:description}][${2:#{n}}]$0" + str.gsub(/[$`\]/, '\\\1') + "[$2]: ${3:http://%7D%5Cn"
-- FredB
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate