diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb index b55287ba4..67e3579df 100644 --- a/lib/redmine/wiki_formatting/textile/formatter.rb +++ b/lib/redmine/wiki_formatting/textile/formatter.rb @@ -65,7 +65,7 @@ module Redmine # Patch to add 'table of content' support to RedCloth def textile_p_withtoc(tag, atts, cite, content) # removes wiki links from the item - toc_item = content.gsub(/(\[\[|\]\])/, '') + toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 } # removes styles # eg. %{color:red}Triggers% => Triggers toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1' diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 9fbb3f653..26912f587 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -293,10 +293,12 @@ h1. Title Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. -h2. Subtitle +h2. Subtitle with a [[Wiki]] link Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. +h2. Subtitle with [[Wiki|another Wiki]] link + h2. Subtitle with %{color:red}red text% h1. Another title @@ -305,11 +307,12 @@ RAW expected = '