##// END OF EJS Templates
Fixed: TOC does not remove colorization markups (#1423)....
Jean-Philippe Lang -
r1528:11e9891425c4
parent child
Show More
@@ -85,6 +85,9 module Redmine
85 85 @toc.each_with_index do |heading, index|
86 86 # remove wiki links from the item
87 87 toc_item = heading.last.gsub(/(\[\[|\]\])/, '')
88 # remove styles
89 # eg. %{color:red}Triggers% => Triggers
90 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
88 91 out << "<a href=\"##{index+1}\" class=\"heading#{heading.first}\">#{toc_item}</a>"
89 92 end
90 93 out << '</div>'
@@ -183,6 +183,34 class ApplicationHelperTest < HelperTestCase
183 183 assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
184 184 end
185 185
186 def test_table_of_content
187 raw = <<-RAW
188 {{toc}}
189
190 h1. Title
191
192 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
193
194 h2. Subtitle
195
196 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
197
198 h2. Subtitle with %{color:red}red text%
199
200 h1. Another title
201
202 RAW
203
204 expected = '<div class="toc">' +
205 '<a href="#1" class="heading1">Title</a>' +
206 '<a href="#2" class="heading2">Subtitle</a>' +
207 '<a href="#3" class="heading2">Subtitle with red text</a>' +
208 '<a href="#4" class="heading1">Another title</a>' +
209 '</div>'
210
211 assert textilizable(raw).include?(expected)
212 end
213
186 214 def test_blockquote
187 215 # orig raw text
188 216 raw = <<-RAW
General Comments 0
You need to be logged in to leave comments. Login now