From dcdf4bf9e0e3936615be6a73687fc7138edebaa8 Mon Sep 17 00:00:00 2001 From: Code Ass Date: Thu, 9 Nov 2017 02:22:25 +0900 Subject: [PATCH] Fix tag in table_of_contents.html RDoc::Markup::AttributeManager#convert_html that is called from RDoc::Markup::AttributeManager#flow replaces HTML tags of received "str" with "NULL" characters in HTML generation for each files, and the NULL characters are removed in RDoc::Markup::AttributeManager#split_into_flow. But the String objects are reused for table_of_contents.html generation, so the tags lose at that moment. This commit fixes it with using duplicated String object. --- lib/rdoc/markup/attribute_manager.rb | 2 +- test/test_rdoc_markup_attribute_manager.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb index 3296d17af2..6edb30b867 100644 --- a/lib/rdoc/markup/attribute_manager.rb +++ b/lib/rdoc/markup/attribute_manager.rb @@ -246,7 +246,7 @@ def add_special pattern, name # Processes +str+ converting attributes, HTML and specials def flow str - @str = str + @str = str.dup mask_protected_sequences diff --git a/test/test_rdoc_markup_attribute_manager.rb b/test/test_rdoc_markup_attribute_manager.rb index c0f7666a01..b51e422474 100644 --- a/test/test_rdoc_markup_attribute_manager.rb +++ b/test/test_rdoc_markup_attribute_manager.rb @@ -332,6 +332,14 @@ def test_protect @am.flow("\\_cat_dog")) end + def test_lost_tag_for_the_second_time + str = "cat dog" + assert_equal(["cat ", @tt_on, "dog", @tt_off], + @am.flow(str)) + assert_equal(["cat ", @tt_on, "dog", @tt_off], + @am.flow(str)) + end + def test_special @am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF)