diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb
index abffdbc..4c18278 100644
--- a/lib/redmine/wiki_formatting/textile/formatter.rb
+++ b/lib/redmine/wiki_formatting/textile/formatter.rb
@@ -65,12 +65,9 @@ module Redmine
         def textile_p_withtoc(tag, atts, cite, content)
           # removes wiki links from the item
           toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
-          # sanitizes titles from links
-          # see redcloth3.rb, same as "#{pre}#{text}#{post}"
-          toc_item.gsub!(LINK_RE) { $2+$4+$9 }
-          # removes styles
-          # eg. %{color:red}Triggers% => Triggers
-          toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
+          
+          # removes inline textile
+          toc_item = RedCloth3.new(toc_item).to_html.gsub(/<[^>]+?>/,'')
           
           # replaces non word caracters by dashes
           anchor = toc_item.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 534135e..ec13de7 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -421,6 +421,8 @@ h2. Subtitle with %{color:red}red text%
 h1. Another title
 
 h2. An "Internet link":http://www.redmine.org/ inside subtitle
+
+h2. @Subtitle@ *with* _various_ -stupid- +styles+
 RAW
 
     expected = '<ul class="toc">' +
@@ -430,6 +432,7 @@ RAW
                '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
                '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
                '<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
+               '<li class="heading2"><a href="#Subtitle-with-various-stupid-styles">Subtitle with various stupid styles</a></li>' +
                '</ul>'
                
     assert textilizable(raw).gsub("\n", "").include?(expected)
