diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-06-15 11:00:40 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-06-15 11:00:40 +0000 |
commit | 11e9891425c4fb59ebeb7080077c1097d3800f8c (patch) | |
tree | 483492b396acb21cd166a27a4cfa87caad08c33a | |
parent | 8b2105e20ac76dba21cd8e313a75a5d52850cf69 (diff) | |
download | redmine-11e9891425c4fb59ebeb7080077c1097d3800f8c.tar.gz redmine-11e9891425c4fb59ebeb7080077c1097d3800f8c.zip |
Fixed: TOC does not remove colorization markups (#1423).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1542 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 3 | ||||
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 7197af2c3..88a858b04 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -85,6 +85,9 @@ module Redmine @toc.each_with_index do |heading, index| # remove wiki links from the item 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>" end out << '</div>' diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 1e75dbd64..7fa96d7e2 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -183,6 +183,34 @@ class ApplicationHelperTest < HelperTestCase assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---') 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 # orig raw text raw = <<-RAW |