diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 3c1eac020..39b81e44a 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 89310326b..bea009e38 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -186,6 +186,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_macro_hello_world text = "{{hello_world}}" assert textilizable(text).match(/Hello world!/)