diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-29 16:33:45 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-01-29 16:33:45 +0000 |
commit | cf566a0c7243010ab8713c08a593027928f31560 (patch) | |
tree | 8998b388ba0692b05b38e0d14ae788f8a5ccfeb5 | |
parent | 945ec8942a4c43ed41aa4302cbe74ad45f1ff08c (diff) | |
download | redmine-cf566a0c7243010ab8713c08a593027928f31560.tar.gz redmine-cf566a0c7243010ab8713c08a593027928f31560.zip |
Fixed: TOC does not parse wiki page reference links with description (#2601).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2336 e93f8b46-1217-0410-a6f0-8f06a7374b81
-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 |