Display the link name when external links are used in the toc macro. #5445
Contributed by Yuki Kita and Jean-Baptiste Barth git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3786 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
69d9600f48
commit
b53de502ab
|
@ -65,6 +65,9 @@ module Redmine
|
||||||
def textile_p_withtoc(tag, atts, cite, content)
|
def textile_p_withtoc(tag, atts, cite, content)
|
||||||
# removes wiki links from the item
|
# removes wiki links from the item
|
||||||
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
|
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
|
||||||
|
# sanitizes titles from links
|
||||||
|
# see redcloth3.rb, same as "#{pre}#{text}#{post}"
|
||||||
|
toc_item.gsub!(LINK_RE) { $2+$4+$9 }
|
||||||
# removes styles
|
# removes styles
|
||||||
# eg. %{color:red}Triggers% => Triggers
|
# eg. %{color:red}Triggers% => Triggers
|
||||||
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
|
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
|
||||||
|
|
|
@ -420,6 +420,7 @@ h2. Subtitle with %{color:red}red text%
|
||||||
|
|
||||||
h1. Another title
|
h1. Another title
|
||||||
|
|
||||||
|
h2. An "Internet link":http://www.redmine.org/ inside subtitle
|
||||||
RAW
|
RAW
|
||||||
|
|
||||||
expected = '<ul class="toc">' +
|
expected = '<ul class="toc">' +
|
||||||
|
@ -428,6 +429,7 @@ RAW
|
||||||
'<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another 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="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
|
||||||
'<li class="heading1"><a href="#Another-title">Another title</a></li>' +
|
'<li class="heading1"><a href="#Another-title">Another title</a></li>' +
|
||||||
|
'<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
|
||||||
'</ul>'
|
'</ul>'
|
||||||
|
|
||||||
assert textilizable(raw).gsub("\n", "").include?(expected)
|
assert textilizable(raw).gsub("\n", "").include?(expected)
|
||||||
|
|
Loading…
Reference in New Issue