Index: lib/redmine/wiki_formatting/textile/formatter.rb
===================================================================
--- lib/redmine/wiki_formatting/textile/formatter.rb	(revision 3750)
+++ lib/redmine/wiki_formatting/textile/formatter.rb	(working copy)
@@ -37,7 +37,32 @@
           @toc = []
           super(*RULES).to_s
         end
-  
+        
+        def clear_toc_of_links!
+
+          str = self.scan(/("[a-z0-9]+":(http|https):\/\/?(?:[-a-z0-9]+\.)+[a-z]{2,}(:[0-9]{1,5})?(\/*)?)/ix)
+          size = str.size
+
+          linkslist = Array.new(size)
+          linkslist.map! { Array.new(1) }
+
+          i = 0
+
+          str.each do |t|
+            linkslist[i][0] = t[0].to_s
+            tmpstr = linkslist[i].to_s
+            tmpstr.delete! '"'
+            tmpstr.delete! ":"
+            linkstr = tmpstr.scan(/((http|https):?\/\/?(?:[-a-z0-9]+\.)+[a-z]{2,}(:[0-9]{1,5})?(\/*)?)/ix)
+            delstr = linkstr[0][0].to_s
+            tmpstr.gsub!(delstr, '')
+            linkslist[i][1] = tmpstr
+            self.gsub!(linkslist[i][0], linkslist[i][1])
+            i = i + 1
+          end
+          self.to_s
+        end 
+      
       private
   
         # Patch for RedCloth.  Fixed in RedCloth r128 but _why hasn't released it yet.
@@ -85,7 +110,7 @@
         alias :textile_h1 :textile_p_withtoc
         alias :textile_h2 :textile_p_withtoc
         alias :textile_h3 :textile_p_withtoc
-        
+
         def inline_toc(text)
           text.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i) do
             div_class = 'toc'
@@ -94,6 +119,7 @@
             out = "<ul class=\"#{div_class}\">"
             @toc.each do |heading|
               level, anchor, toc_item = heading
+              toc_item.clear_toc_of_links!
               out << "<li class=\"heading#{level}\"><a href=\"##{anchor}\">#{toc_item}</a></li>\n"
             end
             out << '</ul>'

