Fixed: TOC does not remove colorization markups (#1423).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1542 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8b2105e20a
commit
11e9891425
|
@ -85,6 +85,9 @@ module Redmine
|
||||||
@toc.each_with_index do |heading, index|
|
@toc.each_with_index do |heading, index|
|
||||||
# remove wiki links from the item
|
# remove wiki links from the item
|
||||||
toc_item = heading.last.gsub(/(\[\[|\]\])/, '')
|
toc_item = heading.last.gsub(/(\[\[|\]\])/, '')
|
||||||
|
# remove styles
|
||||||
|
# eg. %{color:red}Triggers% => Triggers
|
||||||
|
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
|
||||||
out << "<a href=\"##{index+1}\" class=\"heading#{heading.first}\">#{toc_item}</a>"
|
out << "<a href=\"##{index+1}\" class=\"heading#{heading.first}\">#{toc_item}</a>"
|
||||||
end
|
end
|
||||||
out << '</div>'
|
out << '</div>'
|
||||||
|
|
|
@ -183,6 +183,34 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
|
assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_table_of_content
|
||||||
|
raw = <<-RAW
|
||||||
|
{{toc}}
|
||||||
|
|
||||||
|
h1. Title
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
|
||||||
|
|
||||||
|
h2. Subtitle
|
||||||
|
|
||||||
|
Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
|
||||||
|
|
||||||
|
h2. Subtitle with %{color:red}red text%
|
||||||
|
|
||||||
|
h1. Another title
|
||||||
|
|
||||||
|
RAW
|
||||||
|
|
||||||
|
expected = '<div class="toc">' +
|
||||||
|
'<a href="#1" class="heading1">Title</a>' +
|
||||||
|
'<a href="#2" class="heading2">Subtitle</a>' +
|
||||||
|
'<a href="#3" class="heading2">Subtitle with red text</a>' +
|
||||||
|
'<a href="#4" class="heading1">Another title</a>' +
|
||||||
|
'</div>'
|
||||||
|
|
||||||
|
assert textilizable(raw).include?(expected)
|
||||||
|
end
|
||||||
|
|
||||||
def test_blockquote
|
def test_blockquote
|
||||||
# orig raw text
|
# orig raw text
|
||||||
raw = <<-RAW
|
raw = <<-RAW
|
||||||
|
|
Loading…
Reference in New Issue