diff --git a/lib/table_of_contents/configuration.rb b/lib/table_of_contents/configuration.rb index 595c73d..cb6e6d9 100644 --- a/lib/table_of_contents/configuration.rb +++ b/lib/table_of_contents/configuration.rb @@ -22,10 +22,10 @@ class Configuration def initialize(options) options = generate_option_hash(options) - @toc_levels = options['min_level']..options['max_level'] + @toc_levels = (options['min_level']..options['max_level']).to_a @ordered_list = options['ordered_list'] @no_toc_class = 'no_toc' - @no_toc_section_class = options['no_toc_section_class'] + @no_toc_section_class = Array(options['no_toc_section_class']) @list_id = options['list_id'] @list_class = options['list_class'] @sublist_class = options['sublist_class'] diff --git a/lib/table_of_contents/parser.rb b/lib/table_of_contents/parser.rb index 23509cc..fb5d793 100644 --- a/lib/table_of_contents/parser.rb +++ b/lib/table_of_contents/parser.rb @@ -24,12 +24,8 @@ def build_toc def inject_anchors_into_html @entries.each do |entry| - # NOTE: `entry[:id]` is automatically URL encoded by Nokogiri - entry[:header_content].add_previous_sibling( - %() - ) + entry[:header_content].wrap(%()) end - @doc.inner_html end diff --git a/test/parser/test_inject_anchors_filter.rb b/test/parser/test_inject_anchors_filter.rb index 61d00b9..03bcd1b 100644 --- a/test/parser/test_inject_anchors_filter.rb +++ b/test/parser/test_inject_anchors_filter.rb @@ -12,8 +12,9 @@ def setup def test_injects_anchors_into_content html = @parser.inject_anchors_into_html - assert_match(%r{Simple H1}, html) + assert_match(%r{}, html) end + def test_does_not_inject_toc html = @parser.inject_anchors_into_html diff --git a/test/parser/test_toc_filter.rb b/test/parser/test_toc_filter.rb index 6fe2fb7..ebd8103 100644 --- a/test/parser/test_toc_filter.rb +++ b/test/parser/test_toc_filter.rb @@ -12,7 +12,7 @@ def setup def test_injects_anchors html = @parser.toc - assert_match(%r{Simple H1}, html) + assert_match(%r{}, html) end def test_nested_toc diff --git a/test/parser/test_various_toc_html.rb b/test/parser/test_various_toc_html.rb index 9fdd221..6cb6e4d 100644 --- a/test/parser/test_various_toc_html.rb +++ b/test/parser/test_various_toc_html.rb @@ -172,9 +172,9 @@ def test_japanese_toc assert_equal(expected, parser.build_toc) html_with_anchors = parser.inject_anchors_into_html - assert_match(%r{あ}, html_with_anchors) - assert_match(%r{い}, html_with_anchors) - assert_match(%r{う}, html_with_anchors) + assert_match(%r{}, html_with_anchors) + assert_match(%r{}, html_with_anchors) + assert_match(%r{}, html_with_anchors) end # ref. https://github.com/toshimaru/jekyll-toc/issues/45 diff --git a/test/test_configuration.rb b/test/test_configuration.rb index a3e77c9..f0d16dd 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -6,9 +6,9 @@ class TestConfiguration < Minitest::Test def test_default_configuration configuration = Jekyll::TableOfContents::Configuration.new({}) - assert_equal(1..6, configuration.toc_levels) + assert_equal((1..6).to_a, configuration.toc_levels) refute(configuration.ordered_list) - assert_equal('no_toc_section', configuration.no_toc_section_class) + assert_equal(['no_toc_section'], configuration.no_toc_section_class) assert_equal('toc', configuration.list_id) assert_equal('section-nav', configuration.list_class) assert_equal('', configuration.sublist_class) @@ -19,9 +19,9 @@ def test_default_configuration def test_type_error configuration = Jekyll::TableOfContents::Configuration.new('TypeError!') - assert_equal(1..6, configuration.toc_levels) + assert_equal((1..6).to_a, configuration.toc_levels) refute(configuration.ordered_list) - assert_equal('no_toc_section', configuration.no_toc_section_class) + assert_equal(['no_toc_section'], configuration.no_toc_section_class) assert_equal('toc', configuration.list_id) assert_equal('section-nav', configuration.list_class) assert_equal('', configuration.sublist_class)