##// END OF EJS Templates
Display the link name when external links are used in the toc macro. #5445...
Eric Davis -
r3672:b53de502ab60
parent child
Show More
@@ -65,6 +65,9 module Redmine
65 def textile_p_withtoc(tag, atts, cite, content)
65 def textile_p_withtoc(tag, atts, cite, content)
66 # removes wiki links from the item
66 # removes wiki links from the item
67 toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
67 toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
68 # sanitizes titles from links
69 # see redcloth3.rb, same as "#{pre}#{text}#{post}"
70 toc_item.gsub!(LINK_RE) { $2+$4+$9 }
68 # removes styles
71 # removes styles
69 # eg. %{color:red}Triggers% => Triggers
72 # eg. %{color:red}Triggers% => Triggers
70 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
73 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
@@ -420,6 +420,7 h2. Subtitle with %{color:red}red text%
420
420
421 h1. Another title
421 h1. Another title
422
422
423 h2. An "Internet link":http://www.redmine.org/ inside subtitle
423 RAW
424 RAW
424
425
425 expected = '<ul class="toc">' +
426 expected = '<ul class="toc">' +
@@ -428,6 +429,7 RAW
428 '<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
429 '<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
429 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
430 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
430 '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
431 '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
432 '<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
431 '</ul>'
433 '</ul>'
432
434
433 assert textilizable(raw).gsub("\n", "").include?(expected)
435 assert textilizable(raw).gsub("\n", "").include?(expected)
General Comments 0
You need to be logged in to leave comments. Login now