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 << "#{toc_item}" end out << '' 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 '

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