From cf566a0c7243010ab8713c08a593027928f31560 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 29 Jan 2009 16:33:45 +0000 Subject: [PATCH] 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 --- lib/redmine/wiki_formatting/textile/formatter.rb | 2 +- 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 = '' - + puts textilizable(raw) assert textilizable(raw).gsub("\n", "").include?(expected) end