From 11e9891425c4fb59ebeb7080077c1097d3800f8c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Jun 2008 11:00:40 +0000 Subject: [PATCH] Fixed: TOC does not remove colorization markups (#1423). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1542 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting.rb | 3 +++ test/unit/helpers/application_helper_test.rb | 28 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 7197af2c..88a858b0 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 << "#{toc_item}" end out << '' diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 1e75dbd6..7fa96d7e 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 '

Dashes: ---

', 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 = '
' + + 'Title' + + 'Subtitle' + + 'Subtitle with red text' + + 'Another title' + + '
' + + assert textilizable(raw).include?(expected) + end + def test_blockquote # orig raw text raw = <<-RAW