diff options
-rw-r--r-- | lib/redmine/wiki_formatting/textile/formatter.rb | 2 | ||||
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 9 |
2 files changed, 7 insertions, 4 deletions
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 = '<ul class="toc">' + '<li class="heading1"><a href="#Title">Title</a></li>' + - '<li class="heading2"><a href="#Subtitle">Subtitle</a></li>' + + '<li class="heading2"><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' + + '<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' + '<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>' + '</ul>' - + puts textilizable(raw) assert textilizable(raw).gsub("\n", "").include?(expected) end |