Commit cf566a0c authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

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
parent 945ec894
......@@ -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'
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment