From e8057d41bbba530feef2ac56ead50e0bb635cb8f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 15 Feb 2014 10:55:29 +0000 Subject: [PATCH] Fixed that collapse macro with headings breaks the table of contents (#16077). git-svn-id: http://svn.redmine.org/redmine/trunk@12899 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting/macros.rb | 2 +- .../lib/redmine/wiki_formatting/macros_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index e55d5de32..731c1bc00 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -221,7 +221,7 @@ module Redmine out = ''.html_safe out << link_to_function(show_label, js, :id => "#{html_id}-show", :class => 'collapsible collapsed') out << link_to_function(hide_label, js, :id => "#{html_id}-hide", :class => 'collapsible', :style => 'display:none;') - out << content_tag('div', textilizable(text, :object => obj), :id => html_id, :class => 'collapsed-text', :style => 'display:none;') + out << content_tag('div', textilizable(text, :object => obj, :headings => false), :id => html_id, :class => 'collapsed-text', :style => 'display:none;') out end diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index 772fa9555..da0094c0b 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -235,6 +235,22 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase assert_select_in result, 'a.collapsible', :text => 'Hide example' end + def test_macro_collapse_should_not_break_toc + text = <<-RAW +{{toc}} + +h1. Title + +{{collapse(Show example, Hide example) +h2. Heading +}}" +RAW + + expected_toc = '' + + assert_include expected_toc, textilizable(text).gsub(/[\r\n]/, '') + end + def test_macro_child_pages expected = "