#!/usr/bin/env ruby

footies = Hash.new(false)

while chunk = STDIN.gets do
   while chunk =~ /\[(\d+)\]/ do
      cur_footie = $1
      if footies[cur_footie] 
         chunk.sub!(/\[#{cur_footie}\]/, "[<a href=#ft#{$1} id=fb#{$1}>#{$1}</a>]")
      else
         footies[cur_footie] = true
         chunk.sub!(/\[#{cur_footie}\]/, "[<a href=#fb#{$1} id=ft#{$1}>#{$1}</a>]")
      end
   end   
   puts chunk
end

