jekyll-toc 0.13.1 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +19 -0
- data/.github/workflows/ci.yml +11 -5
- data/.github/workflows/coverage.yml +15 -14
- data/.github/workflows/rubocop.yml +12 -11
- data/.rubocop.yml +24 -9
- data/Appraisals +5 -9
- data/Gemfile +4 -1
- data/README.md +99 -33
- data/gemfiles/jekyll_3.8.gemfile +4 -1
- data/gemfiles/{jekyll_3.7.gemfile → jekyll_3.9.gemfile} +5 -2
- data/gemfiles/jekyll_4.0.gemfile +4 -1
- data/gemfiles/jekyll_4.1.gemfile +17 -0
- data/gemfiles/jekyll_4.2.gemfile +17 -0
- data/jekyll-toc.gemspec +6 -6
- data/lib/table_of_contents/configuration.rb +6 -2
- data/lib/table_of_contents/helper.rb +17 -0
- data/lib/table_of_contents/parser.rb +12 -8
- data/lib/table_of_contents/version.rb +7 -0
- data/test/parser/test_inject_anchors_filter.rb +1 -1
- data/test/parser/test_invalid_options.rb +32 -0
- data/test/parser/test_ordered_list.rb +76 -0
- data/test/parser/test_toc_filter.rb +1 -1
- data/test/parser/test_toc_only_filter.rb +2 -2
- data/test/parser/test_various_toc_html.rb +163 -230
- data/test/test_configuration.rb +17 -13
- data/test/test_helper.rb +2 -2
- data/test/test_jekyll-toc.rb +2 -2
- data/test/test_kramdown_list.rb +5 -5
- data/test/test_toc_tag.rb +1 -1
- metadata +22 -16
- data/lib/version.rb +0 -5
- data/test/parser/test_option_error.rb +0 -40
data/test/test_configuration.rb
CHANGED
@@ -3,25 +3,29 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class TestConfiguration < Minitest::Test
|
6
|
-
def
|
6
|
+
def test_default_configuration
|
7
7
|
configuration = Jekyll::TableOfContents::Configuration.new({})
|
8
8
|
|
9
|
-
assert_equal configuration.toc_levels
|
10
|
-
|
11
|
-
assert_equal configuration.
|
12
|
-
assert_equal configuration.
|
13
|
-
assert_equal configuration.
|
14
|
-
assert_equal configuration.
|
9
|
+
assert_equal(1..6, configuration.toc_levels)
|
10
|
+
refute(configuration.ordered_list)
|
11
|
+
assert_equal('no_toc_section', configuration.no_toc_section_class)
|
12
|
+
assert_equal('toc', configuration.list_id)
|
13
|
+
assert_equal('section-nav', configuration.list_class)
|
14
|
+
assert_equal('', configuration.sublist_class)
|
15
|
+
assert_equal('toc-entry', configuration.item_class)
|
16
|
+
assert_equal('toc-', configuration.item_prefix)
|
15
17
|
end
|
16
18
|
|
17
19
|
def test_type_error
|
18
20
|
configuration = Jekyll::TableOfContents::Configuration.new('TypeError!')
|
19
21
|
|
20
|
-
assert_equal configuration.toc_levels
|
21
|
-
|
22
|
-
assert_equal configuration.
|
23
|
-
assert_equal configuration.
|
24
|
-
assert_equal configuration.
|
25
|
-
assert_equal configuration.
|
22
|
+
assert_equal(1..6, configuration.toc_levels)
|
23
|
+
refute(configuration.ordered_list)
|
24
|
+
assert_equal('no_toc_section', configuration.no_toc_section_class)
|
25
|
+
assert_equal('toc', configuration.list_id)
|
26
|
+
assert_equal('section-nav', configuration.list_class)
|
27
|
+
assert_equal('', configuration.sublist_class)
|
28
|
+
assert_equal('toc-entry', configuration.item_class)
|
29
|
+
assert_equal('toc-', configuration.item_prefix)
|
26
30
|
end
|
27
31
|
end
|
data/test/test_helper.rb
CHANGED
@@ -20,7 +20,7 @@ SIMPLE_HTML = <<~HTML
|
|
20
20
|
HTML
|
21
21
|
|
22
22
|
module TestHelpers
|
23
|
-
def read_html_and_create_parser
|
24
|
-
@parser = Jekyll::TableOfContents::Parser.new(SIMPLE_HTML)
|
23
|
+
def read_html_and_create_parser(options = {})
|
24
|
+
@parser = Jekyll::TableOfContents::Parser.new(SIMPLE_HTML, options)
|
25
25
|
end
|
26
26
|
end
|
data/test/test_jekyll-toc.rb
CHANGED
@@ -24,7 +24,7 @@ class TestTableOfContentsFilter < Minitest::Test
|
|
24
24
|
|
25
25
|
def test_toc_only2
|
26
26
|
@context = enable_toc_context
|
27
|
-
assert_equal
|
27
|
+
assert_equal %(<ul id="toc" class="section-nav">\n</ul>), toc_only(DUMMY_HTML)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_inject_anchors2
|
@@ -34,7 +34,7 @@ class TestTableOfContentsFilter < Minitest::Test
|
|
34
34
|
|
35
35
|
def test_toc2
|
36
36
|
@context = enable_toc_context
|
37
|
-
assert_equal
|
37
|
+
assert_equal %(<ul id="toc" class="section-nav">\n</ul>#{DUMMY_HTML}), toc(DUMMY_HTML)
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
data/test/test_kramdown_list.rb
CHANGED
@@ -36,7 +36,7 @@ class TestKramdownList < Minitest::Test
|
|
36
36
|
assert_equal(expected, actual)
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def test_kramdown_list_l1_l5
|
40
40
|
text = <<~MARKDOWN
|
41
41
|
* level-1
|
42
42
|
* level-2
|
@@ -70,7 +70,7 @@ class TestKramdownList < Minitest::Test
|
|
70
70
|
assert_equal(expected, actual)
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def test_kramdown_list_l1_l3_l2_l4
|
74
74
|
text = <<~MARKDOWN
|
75
75
|
* level-1
|
76
76
|
* level-3
|
@@ -101,7 +101,7 @@ class TestKramdownList < Minitest::Test
|
|
101
101
|
assert_equal(expected, actual)
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
104
|
+
def test_kramdown_list_l4_l1
|
105
105
|
text = <<~MARKDOWN
|
106
106
|
* level-4
|
107
107
|
* level-3
|
@@ -118,7 +118,7 @@ class TestKramdownList < Minitest::Test
|
|
118
118
|
assert_equal(expected, actual)
|
119
119
|
end
|
120
120
|
|
121
|
-
def
|
121
|
+
def test_kramdown_list_l1_l4_l1
|
122
122
|
text = <<~MARKDOWN
|
123
123
|
* level-1
|
124
124
|
* level-4
|
@@ -143,7 +143,7 @@ class TestKramdownList < Minitest::Test
|
|
143
143
|
assert_equal(expected, actual)
|
144
144
|
end
|
145
145
|
|
146
|
-
def
|
146
|
+
def test_kramdown_list_l1_l3_l1
|
147
147
|
text = <<~MARKDOWN
|
148
148
|
* level-1
|
149
149
|
* level-3
|
data/test/test_toc_tag.rb
CHANGED
@@ -17,7 +17,7 @@ class TestTableOfContentsTag < Minitest::Test
|
|
17
17
|
site: @stubbed_context1.new({ 'toc' => nil })
|
18
18
|
)
|
19
19
|
tag = Jekyll::TocTag.parse('toc_tag', '', Tokenizer.new(''), ParseContext.new)
|
20
|
-
assert_equal
|
20
|
+
assert_equal(%(<ul id="toc" class="section-nav">\n<li class="toc-entry toc-h1"><a href="#test">test</a></li>\n</ul>), tag.render(context))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_toc_tag_returns_empty_string
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-toc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toshimaru
|
8
8
|
- torbjoernk
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -17,35 +17,36 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '3.
|
20
|
+
version: '3.8'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '3.
|
27
|
+
version: '3.8'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: nokogiri
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.10'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
42
|
-
description: Jekyll (Ruby static website generator) plugin which generates a
|
43
|
-
of
|
41
|
+
version: '1.10'
|
42
|
+
description: Jekyll (Ruby static website generator) plugin which generates a Table
|
43
|
+
of Contents for the page.
|
44
44
|
email: me@toshimaru.net
|
45
45
|
executables: []
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- ".github/dependabot.yml"
|
49
50
|
- ".github/workflows/ci.yml"
|
50
51
|
- ".github/workflows/coverage.yml"
|
51
52
|
- ".github/workflows/rubocop.yml"
|
@@ -57,16 +58,20 @@ files:
|
|
57
58
|
- LICENSE.md
|
58
59
|
- README.md
|
59
60
|
- Rakefile
|
60
|
-
- gemfiles/jekyll_3.7.gemfile
|
61
61
|
- gemfiles/jekyll_3.8.gemfile
|
62
|
+
- gemfiles/jekyll_3.9.gemfile
|
62
63
|
- gemfiles/jekyll_4.0.gemfile
|
64
|
+
- gemfiles/jekyll_4.1.gemfile
|
65
|
+
- gemfiles/jekyll_4.2.gemfile
|
63
66
|
- jekyll-toc.gemspec
|
64
67
|
- lib/jekyll-toc.rb
|
65
68
|
- lib/table_of_contents/configuration.rb
|
69
|
+
- lib/table_of_contents/helper.rb
|
66
70
|
- lib/table_of_contents/parser.rb
|
67
|
-
- lib/version.rb
|
71
|
+
- lib/table_of_contents/version.rb
|
68
72
|
- test/parser/test_inject_anchors_filter.rb
|
69
|
-
- test/parser/
|
73
|
+
- test/parser/test_invalid_options.rb
|
74
|
+
- test/parser/test_ordered_list.rb
|
70
75
|
- test/parser/test_toc_filter.rb
|
71
76
|
- test/parser/test_toc_only_filter.rb
|
72
77
|
- test/parser/test_various_toc_html.rb
|
@@ -79,7 +84,7 @@ homepage: https://github.com/toshimaru/jekyll-toc
|
|
79
84
|
licenses:
|
80
85
|
- MIT
|
81
86
|
metadata: {}
|
82
|
-
post_install_message:
|
87
|
+
post_install_message:
|
83
88
|
rdoc_options: []
|
84
89
|
require_paths:
|
85
90
|
- lib
|
@@ -94,13 +99,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
99
|
- !ruby/object:Gem::Version
|
95
100
|
version: '0'
|
96
101
|
requirements: []
|
97
|
-
rubygems_version: 3.1.
|
98
|
-
signing_key:
|
102
|
+
rubygems_version: 3.1.4
|
103
|
+
signing_key:
|
99
104
|
specification_version: 4
|
100
105
|
summary: Jekyll Table of Contents plugin
|
101
106
|
test_files:
|
102
107
|
- test/parser/test_inject_anchors_filter.rb
|
103
|
-
- test/parser/
|
108
|
+
- test/parser/test_invalid_options.rb
|
109
|
+
- test/parser/test_ordered_list.rb
|
104
110
|
- test/parser/test_toc_filter.rb
|
105
111
|
- test/parser/test_toc_only_filter.rb
|
106
112
|
- test/parser/test_various_toc_html.rb
|
data/lib/version.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class TestOptionError < Minitest::Test
|
6
|
-
BASE_HTML = '<h1>h1</h1>'
|
7
|
-
EXPECTED_HTML = <<~HTML
|
8
|
-
<ul class="section-nav">
|
9
|
-
<li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
|
10
|
-
</ul>
|
11
|
-
HTML
|
12
|
-
|
13
|
-
def test_option_is_nil
|
14
|
-
parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, nil)
|
15
|
-
doc = Nokogiri::HTML(parser.toc)
|
16
|
-
expected = EXPECTED_HTML
|
17
|
-
assert_equal(expected, doc.css('ul.section-nav').to_s)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_option_is_epmty_string
|
21
|
-
parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, '')
|
22
|
-
doc = Nokogiri::HTML(parser.toc)
|
23
|
-
expected = EXPECTED_HTML
|
24
|
-
assert_equal(expected, doc.css('ul.section-nav').to_s)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_option_is_string
|
28
|
-
parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, 'string')
|
29
|
-
doc = Nokogiri::HTML(parser.toc)
|
30
|
-
expected = EXPECTED_HTML
|
31
|
-
assert_equal(expected, doc.css('ul.section-nav').to_s)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_option_is_array
|
35
|
-
parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, [])
|
36
|
-
doc = Nokogiri::HTML(parser.toc)
|
37
|
-
expected = EXPECTED_HTML
|
38
|
-
assert_equal(expected, doc.css('ul.section-nav').to_s)
|
39
|
-
end
|
40
|
-
end
|