jekyll-toc 0.9.0.beta1 → 0.9.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: e065b97dcb3e794963823391777d7f7b18858c3bf40ee47a9266f695c2306cb5
4
- data.tar.gz: f2be7aea0ba994d5aa8348f37c0d85080dcd9aebfa7d2e8ec9e1611802efacf7
2
+ SHA1:
3
+ metadata.gz: ca7dd03b5aa971d3b28ea66a4085fb8ed638d868
4
+ data.tar.gz: 1e389ea8b3cc7eaf1e4439644448144acc7b3b69
5
5
  SHA512:
6
- metadata.gz: 14af1dc403067ef8ce268acbdb7f6a8af5712be0f8d59f77736dfd46ff31607c5073595c5d984c336022202f41e62c8d72128e9a86865c6d80092026ae06008a
7
- data.tar.gz: e396d673df7bad05f79cf218b49ab690e275b3ec943821c5b7e65387f7ac3c8226bee0cc13555cbbead5bf7f8d9685ea4d41559c49a77e96d1987b77d16a0018
6
+ metadata.gz: 50517ee387e77ab7207828b89ac578b074ddbb4f9b0bb6d48741aefd2c5833492e0c8d006587c7640b70c3f48517ff237e3f170cc7d3af220964afff8d1a0ac6
7
+ data.tar.gz: a3bd134c5850750fdab39aad27e6126d895ab0ca1358e592e39027b05e201439f968a608aa99a51208356f62916b75ff039c9291c44da26bc6df66c895858c79
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ Exclude:
4
+ - 'gemfiles/*'
5
+
6
+ Metrics/LineLength:
7
+ Max: 100
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.2
5
4
  - 2.3.7
6
5
  - 2.4.4
7
6
  - 2.5.1
data/Appraisals CHANGED
@@ -1,15 +1,17 @@
1
- appraise "jekyll-3.8" do
2
- gem "jekyll", "3.8"
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'jekyll-3.8' do
4
+ gem 'jekyll', '3.8'
3
5
  end
4
6
 
5
- appraise "jekyll-3.7" do
6
- gem "jekyll", "3.7"
7
+ appraise 'jekyll-3.7' do
8
+ gem 'jekyll', '3.7'
7
9
  end
8
10
 
9
- appraise "jekyll-3.6" do
10
- gem "jekyll", "3.6"
11
+ appraise 'jekyll-3.6' do
12
+ gem 'jekyll', '3.6'
11
13
  end
12
14
 
13
- appraise "jekyll-3.5" do
14
- gem "jekyll", "3.5"
15
+ appraise 'jekyll-3.5' do
16
+ gem 'jekyll', '3.5'
15
17
  end
data/jekyll-toc.gemspec CHANGED
@@ -15,9 +15,9 @@ Gem::Specification.new do |spec|
15
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
16
  spec.require_paths = ['lib']
17
17
 
18
- spec.required_ruby_version = '>= 2.2.2'
18
+ spec.required_ruby_version = '>= 2.3'
19
19
 
20
- spec.add_runtime_dependency 'nokogiri', '~> 1.7'
20
+ spec.add_runtime_dependency 'nokogiri', '~> 1.8'
21
21
 
22
22
  spec.add_development_dependency 'appraisal'
23
23
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
data/lib/jekyll-toc.rb CHANGED
@@ -4,27 +4,31 @@ require 'nokogiri'
4
4
  require 'table_of_contents/parser'
5
5
 
6
6
  module Jekyll
7
- class TocTag < Liquid::Tag
8
- def render(context)
9
- return unless context.registers[:page]['toc'] == true
10
- content_html = context.registers[:page].content
11
- ::Jekyll::TableOfContents::Parser.new(content_html).build_toc
12
- end
13
- end
7
+ # class TocTag < Liquid::Tag
8
+ # def render(context)
9
+ # return unless context.registers[:page]['toc']
10
+ #
11
+ # content_html = context.registers[:page].content
12
+ # ::Jekyll::TableOfContents::Parser.new(content_html).build_toc
13
+ # end
14
+ # end
14
15
 
15
16
  module TableOfContentsFilter
16
17
  def toc_only(html)
17
18
  return html unless toc_enabled?
19
+
18
20
  ::Jekyll::TableOfContents::Parser.new(html, toc_config).build_toc
19
21
  end
20
22
 
21
23
  def inject_anchors(html)
22
24
  return html unless toc_enabled?
25
+
23
26
  ::Jekyll::TableOfContents::Parser.new(html, toc_config).inject_anchors_into_html
24
27
  end
25
28
 
26
29
  def toc(html)
27
30
  return html unless toc_enabled?
31
+
28
32
  ::Jekyll::TableOfContents::Parser.new(html, toc_config).toc
29
33
  end
30
34
 
@@ -11,10 +11,10 @@ module Jekyll
11
11
  'no_toc_section_class' => 'no_toc_section',
12
12
  'min_level' => 1,
13
13
  'max_level' => 6,
14
- "list_class" => "section-nav",
15
- "sublist_class" => "",
16
- "item_class" => "toc-entry",
17
- "item_prefix" => "toc-"
14
+ 'list_class' => 'section-nav',
15
+ 'sublist_class' => '',
16
+ 'item_class' => 'toc-entry',
17
+ 'item_prefix' => 'toc-'
18
18
  }.freeze
19
19
 
20
20
  def initialize(html, options = {})
@@ -22,10 +22,10 @@ module Jekyll
22
22
  options = generate_option_hash(options)
23
23
  @toc_levels = options['min_level']..options['max_level']
24
24
  @no_toc_section_class = options['no_toc_section_class']
25
- @list_class = options["list_class"]
26
- @sublist_class = options["sublist_class"]
27
- @item_class = options["item_class"]
28
- @item_prefix = options["item_prefix"]
25
+ @list_class = options['list_class']
26
+ @sublist_class = options['sublist_class']
27
+ @item_class = options['item_class']
28
+ @item_prefix = options['item_prefix']
29
29
  @entries = parse_content
30
30
  end
31
31
 
@@ -61,7 +61,7 @@ module Jekyll
61
61
  .gsub(PUNCTUATION_REGEXP, '') # remove punctuation
62
62
  .tr(' ', '-') # replace spaces with dash
63
63
 
64
- uniq = headers[id] > 0 ? "-#{headers[id]}" : ''
64
+ uniq = headers[id].positive? ? "-#{headers[id]}" : ''
65
65
  headers[id] += 1
66
66
  header_content = node.children.first
67
67
  next entries unless header_content
@@ -80,12 +80,12 @@ module Jekyll
80
80
  # Returns the list items for entries
81
81
  def build_toc_list(entries)
82
82
  i = 0
83
- toc_list = ''.dup
83
+ toc_list = +''
84
84
  min_h_num = entries.map { |e| e[:h_num] }.min
85
85
 
86
86
  while i < entries.count
87
87
  entry = entries[i]
88
- ul_attributes = @sublist_class.empty? ? "" : %( class="#{@sublist_class}")
88
+ ul_attributes = @sublist_class.empty? ? '' : %( class="#{@sublist_class}")
89
89
  if entry[:h_num] == min_h_num
90
90
  # If the current entry should not be indented in the list, add the entry to the list
91
91
  toc_list << %(<li class="#{@item_class} #{@item_prefix}#{entry[:node_name]}"><a href="##{entry[:id]}#{entry[:uniq]}">#{entry[:text]}</a>)
data/lib/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JekyllToc
2
- VERSION = '0.9.0.beta1'.freeze
4
+ VERSION = '0.9.0.beta2'
3
5
  end
data/test/test_helper.rb CHANGED
@@ -7,7 +7,7 @@ require 'minitest/autorun'
7
7
  require 'jekyll'
8
8
  require 'jekyll-toc'
9
9
 
10
- SIMPLE_HTML = <<-HTML.freeze
10
+ SIMPLE_HTML = <<~HTML
11
11
  <h1>Simple H1</h1>
12
12
  <h2>Simple H2</h2>
13
13
  <h3>Simple H3</h3>
@@ -5,15 +5,15 @@ require 'test_helper'
5
5
  class TestKramdownList < Minitest::Test
6
6
  # NOTE: kramdown automatically injects `id` attribute
7
7
  def test_kramdown_heading
8
- text = <<-MARKDOWN
9
- # h1
8
+ text = <<~MARKDOWN
9
+ # h1
10
10
 
11
- ## h2
11
+ ## h2
12
12
  MARKDOWN
13
- expected = <<-HTML
14
- <h1 id="h1">h1</h1>
13
+ expected = <<~HTML
14
+ <h1 id="h1">h1</h1>
15
15
 
16
- <h2 id="h2">h2</h2>
16
+ <h2 id="h2">h2</h2>
17
17
  HTML
18
18
  actual = Kramdown::Document.new(text).to_html
19
19
 
@@ -21,15 +21,15 @@ class TestKramdownList < Minitest::Test
21
21
  end
22
22
 
23
23
  def test_japanese_heading
24
- text = <<-MARKDOWN
25
- # 日本語見出し1
24
+ text = <<~MARKDOWN
25
+ # 日本語見出し1
26
26
 
27
- ## 日本語見出し2
27
+ ## 日本語見出し2
28
28
  MARKDOWN
29
- expected = <<-HTML
30
- <h1 id="section">日本語見出し1</h1>
29
+ expected = <<~HTML
30
+ <h1 id="section">日本語見出し1</h1>
31
31
 
32
- <h2 id="section-1">日本語見出し2</h2>
32
+ <h2 id="section-1">日本語見出し2</h2>
33
33
  HTML
34
34
  actual = Kramdown::Document.new(text).to_html
35
35
 
@@ -37,33 +37,33 @@ class TestKramdownList < Minitest::Test
37
37
  end
38
38
 
39
39
  def test_kramdown_list_1
40
- text = <<-MARKDOWN
41
- * level-1
42
- * level-2
43
- * level-3
44
- * level-4
45
- * level-5
40
+ text = <<~MARKDOWN
41
+ * level-1
42
+ * level-2
43
+ * level-3
44
+ * level-4
45
+ * level-5
46
46
  MARKDOWN
47
- expected = <<-HTML
48
- <ul>
49
- <li>level-1
50
- <ul>
51
- <li>level-2
52
- <ul>
53
- <li>level-3
54
- <ul>
55
- <li>level-4
56
- <ul>
57
- <li>level-5</li>
58
- </ul>
59
- </li>
60
- </ul>
61
- </li>
62
- </ul>
63
- </li>
64
- </ul>
65
- </li>
66
- </ul>
47
+ expected = <<~HTML
48
+ <ul>
49
+ <li>level-1
50
+ <ul>
51
+ <li>level-2
52
+ <ul>
53
+ <li>level-3
54
+ <ul>
55
+ <li>level-4
56
+ <ul>
57
+ <li>level-5</li>
58
+ </ul>
59
+ </li>
60
+ </ul>
61
+ </li>
62
+ </ul>
63
+ </li>
64
+ </ul>
65
+ </li>
66
+ </ul>
67
67
  HTML
68
68
  actual = Kramdown::Document.new(text).to_html
69
69
 
@@ -71,30 +71,30 @@ class TestKramdownList < Minitest::Test
71
71
  end
72
72
 
73
73
  def test_kramdown_list_2
74
- text = <<-MARKDOWN
75
- * level-1
76
- * level-3
77
- * level-2
78
- * level-4
79
- * level-5
74
+ text = <<~MARKDOWN
75
+ * level-1
76
+ * level-3
77
+ * level-2
78
+ * level-4
79
+ * level-5
80
80
  MARKDOWN
81
- expected = <<-HTML
82
- <ul>
83
- <li>level-1
84
- <ul>
85
- <li>level-3</li>
86
- <li>level-2
87
- <ul>
88
- <li>level-4
89
- <ul>
90
- <li>level-5</li>
91
- </ul>
92
- </li>
93
- </ul>
94
- </li>
95
- </ul>
96
- </li>
97
- </ul>
81
+ expected = <<~HTML
82
+ <ul>
83
+ <li>level-1
84
+ <ul>
85
+ <li>level-3</li>
86
+ <li>level-2
87
+ <ul>
88
+ <li>level-4
89
+ <ul>
90
+ <li>level-5</li>
91
+ </ul>
92
+ </li>
93
+ </ul>
94
+ </li>
95
+ </ul>
96
+ </li>
97
+ </ul>
98
98
  HTML
99
99
  actual = Kramdown::Document.new(text).to_html
100
100
 
@@ -102,16 +102,16 @@ class TestKramdownList < Minitest::Test
102
102
  end
103
103
 
104
104
  def test_kramdown_list_3
105
- text = <<-MARKDOWN
106
- * level-4
107
- * level-3
108
- * level-2
109
- * level-1
105
+ text = <<~MARKDOWN
106
+ * level-4
107
+ * level-3
108
+ * level-2
109
+ * level-1
110
110
  MARKDOWN
111
- expected = <<-HTML
112
- <pre><code> * level-4
113
- * level-3 * level-2 * level-1
114
- </code></pre>
111
+ expected = <<~HTML
112
+ <pre><code> * level-4
113
+ * level-3 * level-2 * level-1
114
+ </code></pre>
115
115
  HTML
116
116
  actual = Kramdown::Document.new(text).to_html
117
117
 
@@ -119,24 +119,24 @@ class TestKramdownList < Minitest::Test
119
119
  end
120
120
 
121
121
  def test_kramdown_list_4
122
- text = <<-MARKDOWN
123
- * level-1
124
- * level-4
125
- * level-3
126
- * level-2
127
- * level-1
122
+ text = <<~MARKDOWN
123
+ * level-1
124
+ * level-4
125
+ * level-3
126
+ * level-2
127
+ * level-1
128
128
  MARKDOWN
129
- expected = <<-HTML
130
- <ul>
131
- <li>level-1
132
- * level-4
133
- <ul>
134
- <li>level-3</li>
135
- <li>level-2</li>
136
- </ul>
137
- </li>
138
- <li>level-1</li>
139
- </ul>
129
+ expected = <<~HTML
130
+ <ul>
131
+ <li>level-1
132
+ * level-4
133
+ <ul>
134
+ <li>level-3</li>
135
+ <li>level-2</li>
136
+ </ul>
137
+ </li>
138
+ <li>level-1</li>
139
+ </ul>
140
140
  HTML
141
141
  actual = Kramdown::Document.new(text).to_html
142
142
 
@@ -144,22 +144,22 @@ class TestKramdownList < Minitest::Test
144
144
  end
145
145
 
146
146
  def test_kramdown_list_5
147
- text = <<-MARKDOWN
148
- * level-1
149
- * level-3
150
- * level-2
151
- * level-1
147
+ text = <<~MARKDOWN
148
+ * level-1
149
+ * level-3
150
+ * level-2
151
+ * level-1
152
152
  MARKDOWN
153
- expected = <<-HTML
154
- <ul>
155
- <li>level-1
156
- <ul>
157
- <li>level-3</li>
158
- <li>level-2</li>
159
- </ul>
160
- </li>
161
- <li>level-1</li>
162
- </ul>
153
+ expected = <<~HTML
154
+ <ul>
155
+ <li>level-1
156
+ <ul>
157
+ <li>level-3</li>
158
+ <li>level-2</li>
159
+ </ul>
160
+ </li>
161
+ <li>level-1</li>
162
+ </ul>
163
163
  HTML
164
164
  actual = Kramdown::Document.new(text).to_html
165
165
 
@@ -4,10 +4,10 @@ require 'test_helper'
4
4
 
5
5
  class TestOptionError < Minitest::Test
6
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>
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
11
  HTML
12
12
 
13
13
  def test_option_is_nil
@@ -4,81 +4,81 @@ require 'test_helper'
4
4
 
5
5
  class TestVariousTocHtml < Minitest::Test
6
6
  # ref. https://github.com/toshimaru/jekyll-toc/issues/45
7
- ANGLE_BRACKET_HTML = <<-HTML
8
- <h1>h1</h1>
9
- <h1>&lt;base href&gt;</h1>
10
- <h1>&amp; &lt; &gt;</h1>
7
+ ANGLE_BRACKET_HTML = <<~HTML
8
+ <h1>h1</h1>
9
+ <h1>&lt;base href&gt;</h1>
10
+ <h1>&amp; &lt; &gt;</h1>
11
11
  HTML
12
12
 
13
- NO_TOC_HTML = <<-HTML
14
- <h1>h1</h1>
15
- <h1 class="no_toc">no_toc h1</h1>
16
- <h2>h2</h2>
17
- <h2 class="no_toc">no_toc h2</h2>
18
- <h3>h3</h3>
19
- <h3 class="no_toc">no_toc h3</h3>
20
- <h4>h4</h4>
21
- <h4 class="no_toc">no_toc h4</h4>
13
+ NO_TOC_HTML = <<~HTML
14
+ <h1>h1</h1>
15
+ <h1 class="no_toc">no_toc h1</h1>
16
+ <h2>h2</h2>
17
+ <h2 class="no_toc">no_toc h2</h2>
18
+ <h3>h3</h3>
19
+ <h3 class="no_toc">no_toc h3</h3>
20
+ <h4>h4</h4>
21
+ <h4 class="no_toc">no_toc h4</h4>
22
22
  HTML
23
23
 
24
- JAPANESE_HEADINGS_HTML = <<-HTML
25
- <h1>あ</h1>
26
- <h2>い</h2>
27
- <h3>う</h3>
24
+ JAPANESE_HEADINGS_HTML = <<~HTML
25
+ <h1>あ</h1>
26
+ <h2>い</h2>
27
+ <h3>う</h3>
28
28
  HTML
29
29
 
30
- TAGS_INSIDE_HEADINGS_HTML = <<-HTML
31
- <h2><strong>h2</strong></h2>
32
- <h2><em>h2</em></h2>
30
+ TAGS_INSIDE_HEADINGS_HTML = <<~HTML
31
+ <h2><strong>h2</strong></h2>
32
+ <h2><em>h2</em></h2>
33
33
  HTML
34
34
 
35
- TEST_HTML_1 = <<-HTML
36
- <h1>h1</h1>
37
- <h3>h3</h3>
38
- <h6>h6</h6>
35
+ TEST_HTML_1 = <<~HTML
36
+ <h1>h1</h1>
37
+ <h3>h3</h3>
38
+ <h6>h6</h6>
39
39
  HTML
40
40
 
41
- TEST_HTML_2 = <<-HTML
42
- <h1>h1</h1>
43
- <h3>h3</h3>
44
- <h2>h2</h2>
45
- <h6>h6</h6>
41
+ TEST_HTML_2 = <<~HTML
42
+ <h1>h1</h1>
43
+ <h3>h3</h3>
44
+ <h2>h2</h2>
45
+ <h6>h6</h6>
46
46
  HTML
47
47
 
48
- TEST_HTML_3 = <<-HTML
49
- <h6>h6</h6>
50
- <h5>h5</h5>
51
- <h4>h4</h4>
52
- <h3>h3</h3>
53
- <h2>h2</h2>
54
- <h1>h1</h1>
48
+ TEST_HTML_3 = <<~HTML
49
+ <h6>h6</h6>
50
+ <h5>h5</h5>
51
+ <h4>h4</h4>
52
+ <h3>h3</h3>
53
+ <h2>h2</h2>
54
+ <h1>h1</h1>
55
55
  HTML
56
56
 
57
- TEST_HTML_4 = <<-HTML
58
- <h1>h1</h1>
59
- <h3>h3</h3>
60
- <h2>h2</h2>
61
- <h4>h4</h4>
62
- <h5>h5</h5>
57
+ TEST_HTML_4 = <<~HTML
58
+ <h1>h1</h1>
59
+ <h3>h3</h3>
60
+ <h2>h2</h2>
61
+ <h4>h4</h4>
62
+ <h5>h5</h5>
63
63
  HTML
64
64
 
65
65
  def test_nested_toc
66
66
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1)
67
67
  doc = Nokogiri::HTML(parser.toc)
68
- expected = <<-HTML
69
- <ul class="section-nav">
70
- <li class="toc-entry toc-h1">
71
- <a href="#h1">h1</a>
72
- <ul>
73
- <li class="toc-entry toc-h3">
74
- <a href="#h3">h3</a>
75
- <ul>
76
- <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
77
- </ul>
78
- </li>
79
- </ul>
80
- </li>
81
- </ul>
68
+ expected = <<~HTML
69
+ <ul class="section-nav">
70
+ <li class="toc-entry toc-h1">
71
+ <a href="#h1">h1</a>
72
+ <ul>
73
+ <li class="toc-entry toc-h3">
74
+ <a href="#h3">h3</a>
75
+ <ul>
76
+ <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
77
+ </ul>
78
+ </li>
79
+ </ul>
80
+ </li>
81
+ </ul>
82
82
  HTML
83
83
  actual = doc.css('ul.section-nav').to_s
84
84
 
@@ -88,10 +88,10 @@ class TestVariousTocHtml < Minitest::Test
88
88
  def test_nested_toc_with_min_and_max
89
89
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1, { 'min_level' => 2, 'max_level' => 5 })
90
90
  doc = Nokogiri::HTML(parser.toc)
91
- expected = <<-HTML
92
- <ul class="section-nav">
93
- <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
94
- </ul>
91
+ expected = <<~HTML
92
+ <ul class="section-nav">
93
+ <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
94
+ </ul>
95
95
  HTML
96
96
  actual = doc.css('ul.section-nav').to_s
97
97
 
@@ -101,21 +101,21 @@ class TestVariousTocHtml < Minitest::Test
101
101
  def test_complex_nested_toc
102
102
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_2)
103
103
  doc = Nokogiri::HTML(parser.toc)
104
- expected = <<-HTML
105
- <ul class="section-nav">
106
- <li class="toc-entry toc-h1">
107
- <a href="#h1">h1</a>
108
- <ul>
109
- <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
110
- <li class="toc-entry toc-h2">
111
- <a href="#h2">h2</a>
112
- <ul>
113
- <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
114
- </ul>
115
- </li>
116
- </ul>
117
- </li>
118
- </ul>
104
+ expected = <<~HTML
105
+ <ul class="section-nav">
106
+ <li class="toc-entry toc-h1">
107
+ <a href="#h1">h1</a>
108
+ <ul>
109
+ <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
110
+ <li class="toc-entry toc-h2">
111
+ <a href="#h2">h2</a>
112
+ <ul>
113
+ <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
114
+ </ul>
115
+ </li>
116
+ </ul>
117
+ </li>
118
+ </ul>
119
119
  HTML
120
120
  actual = doc.css('ul.section-nav').to_s
121
121
 
@@ -125,15 +125,15 @@ class TestVariousTocHtml < Minitest::Test
125
125
  def test_decremental_headings1
126
126
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_3)
127
127
  doc = Nokogiri::HTML(parser.toc)
128
- expected = <<-HTML
129
- <ul class="section-nav">
130
- <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
131
- <li class="toc-entry toc-h5"><a href="#h5">h5</a></li>
132
- <li class="toc-entry toc-h4"><a href="#h4">h4</a></li>
133
- <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
134
- <li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
135
- <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
136
- </ul>
128
+ expected = <<~HTML
129
+ <ul class="section-nav">
130
+ <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
131
+ <li class="toc-entry toc-h5"><a href="#h5">h5</a></li>
132
+ <li class="toc-entry toc-h4"><a href="#h4">h4</a></li>
133
+ <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
134
+ <li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
135
+ <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
136
+ </ul>
137
137
  HTML
138
138
  actual = doc.css('ul.section-nav').to_s
139
139
 
@@ -143,26 +143,26 @@ class TestVariousTocHtml < Minitest::Test
143
143
  def test_decremental_headings2
144
144
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_4)
145
145
  doc = Nokogiri::HTML(parser.toc)
146
- expected = <<-HTML
147
- <ul class="section-nav">
148
- <li class="toc-entry toc-h1">
149
- <a href="#h1">h1</a>
150
- <ul>
151
- <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
152
- <li class="toc-entry toc-h2">
153
- <a href="#h2">h2</a>
154
- <ul>
155
- <li class="toc-entry toc-h4">
156
- <a href="#h4">h4</a>
157
- <ul>
158
- <li class="toc-entry toc-h5"><a href="#h5">h5</a></li>
159
- </ul>
160
- </li>
161
- </ul>
162
- </li>
163
- </ul>
164
- </li>
165
- </ul>
146
+ expected = <<~HTML
147
+ <ul class="section-nav">
148
+ <li class="toc-entry toc-h1">
149
+ <a href="#h1">h1</a>
150
+ <ul>
151
+ <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
152
+ <li class="toc-entry toc-h2">
153
+ <a href="#h2">h2</a>
154
+ <ul>
155
+ <li class="toc-entry toc-h4">
156
+ <a href="#h4">h4</a>
157
+ <ul>
158
+ <li class="toc-entry toc-h5"><a href="#h5">h5</a></li>
159
+ </ul>
160
+ </li>
161
+ </ul>
162
+ </li>
163
+ </ul>
164
+ </li>
165
+ </ul>
166
166
  HTML
167
167
 
168
168
  assert_equal(expected, doc.css('ul.section-nav').to_s)
@@ -171,25 +171,25 @@ class TestVariousTocHtml < Minitest::Test
171
171
  def test_no_toc
172
172
  parser = Jekyll::TableOfContents::Parser.new(NO_TOC_HTML)
173
173
  doc = Nokogiri::HTML(parser.toc)
174
- expected = <<-HTML
175
- <ul class="section-nav">
176
- <li class="toc-entry toc-h1">
177
- <a href="#h1">h1</a>
178
- <ul>
179
- <li class="toc-entry toc-h2">
180
- <a href="#h2">h2</a>
181
- <ul>
182
- <li class="toc-entry toc-h3">
183
- <a href="#h3">h3</a>
184
- <ul>
185
- <li class="toc-entry toc-h4"><a href="#h4">h4</a></li>
186
- </ul>
187
- </li>
188
- </ul>
189
- </li>
190
- </ul>
191
- </li>
192
- </ul>
174
+ expected = <<~HTML
175
+ <ul class="section-nav">
176
+ <li class="toc-entry toc-h1">
177
+ <a href="#h1">h1</a>
178
+ <ul>
179
+ <li class="toc-entry toc-h2">
180
+ <a href="#h2">h2</a>
181
+ <ul>
182
+ <li class="toc-entry toc-h3">
183
+ <a href="#h3">h3</a>
184
+ <ul>
185
+ <li class="toc-entry toc-h4"><a href="#h4">h4</a></li>
186
+ </ul>
187
+ </li>
188
+ </ul>
189
+ </li>
190
+ </ul>
191
+ </li>
192
+ </ul>
193
193
  HTML
194
194
  actual = doc.css('ul.section-nav').to_s
195
195
 
@@ -199,20 +199,20 @@ class TestVariousTocHtml < Minitest::Test
199
199
  def test_japanese_toc
200
200
  parser = Jekyll::TableOfContents::Parser.new(JAPANESE_HEADINGS_HTML)
201
201
  doc = Nokogiri::HTML(parser.toc)
202
- expected = <<-HTML
203
- <ul class="section-nav">
204
- <li class="toc-entry toc-h1">
205
- <a href="#%E3%81%82">あ</a>
206
- <ul>
207
- <li class="toc-entry toc-h2">
208
- <a href="#%E3%81%84">い</a>
209
- <ul>
210
- <li class="toc-entry toc-h3"><a href="#%E3%81%86">う</a></li>
211
- </ul>
212
- </li>
213
- </ul>
214
- </li>
215
- </ul>
202
+ expected = <<~HTML
203
+ <ul class="section-nav">
204
+ <li class="toc-entry toc-h1">
205
+ <a href="#%E3%81%82">あ</a>
206
+ <ul>
207
+ <li class="toc-entry toc-h2">
208
+ <a href="#%E3%81%84">い</a>
209
+ <ul>
210
+ <li class="toc-entry toc-h3"><a href="#%E3%81%86">う</a></li>
211
+ </ul>
212
+ </li>
213
+ </ul>
214
+ </li>
215
+ </ul>
216
216
  HTML
217
217
  actual = doc.css('ul.section-nav').to_s
218
218
 
@@ -222,12 +222,12 @@ class TestVariousTocHtml < Minitest::Test
222
222
  def test_angle_bracket
223
223
  parser = Jekyll::TableOfContents::Parser.new(ANGLE_BRACKET_HTML)
224
224
  doc = Nokogiri::HTML(parser.toc)
225
- expected = <<-HTML
226
- <ul class="section-nav">
227
- <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
228
- <li class="toc-entry toc-h1"><a href="#base-href">&lt;base href&gt;</a></li>
229
- <li class="toc-entry toc-h1"><a href="#--">&amp; &lt; &gt;</a></li>
230
- </ul>
225
+ expected = <<~HTML
226
+ <ul class="section-nav">
227
+ <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
228
+ <li class="toc-entry toc-h1"><a href="#base-href">&lt;base href&gt;</a></li>
229
+ <li class="toc-entry toc-h1"><a href="#--">&amp; &lt; &gt;</a></li>
230
+ </ul>
231
231
  HTML
232
232
  actual = doc.css('ul.section-nav').to_s
233
233
 
@@ -237,43 +237,43 @@ class TestVariousTocHtml < Minitest::Test
237
237
  def test_tags_inside_heading
238
238
  parser = Jekyll::TableOfContents::Parser.new(TAGS_INSIDE_HEADINGS_HTML)
239
239
  doc = Nokogiri::HTML(parser.toc)
240
- expected = <<-HTML
241
- <ul class="section-nav">
242
- <li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
243
- <li class="toc-entry toc-h2"><a href="#h2-1">h2</a></li>
244
- </ul>
240
+ expected = <<~HTML
241
+ <ul class="section-nav">
242
+ <li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
243
+ <li class="toc-entry toc-h2"><a href="#h2-1">h2</a></li>
244
+ </ul>
245
245
  HTML
246
246
  actual = doc.css('ul.section-nav').to_s
247
247
 
248
248
  assert_equal(expected, actual)
249
249
  end
250
250
 
251
- TEST_HTML_IGNORE = <<-HTML
252
- <h1>h1</h1>
253
- <div class="no_toc_section">
254
- <h2>h2</h2>
255
- </div>
256
- <h3>h3</h3>
257
- <h6>h6</h6>
251
+ TEST_HTML_IGNORE = <<~HTML
252
+ <h1>h1</h1>
253
+ <div class="no_toc_section">
254
+ <h2>h2</h2>
255
+ </div>
256
+ <h3>h3</h3>
257
+ <h6>h6</h6>
258
258
  HTML
259
259
 
260
260
  def test_nested_toc_with_no_toc_section_class
261
261
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_IGNORE)
262
262
  doc = Nokogiri::HTML(parser.toc)
263
- expected = <<-HTML
264
- <ul class="section-nav">
265
- <li class="toc-entry toc-h1">
266
- <a href="#h1">h1</a>
267
- <ul>
268
- <li class="toc-entry toc-h3">
269
- <a href="#h3">h3</a>
270
- <ul>
271
- <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
272
- </ul>
273
- </li>
274
- </ul>
275
- </li>
276
- </ul>
263
+ expected = <<~HTML
264
+ <ul class="section-nav">
265
+ <li class="toc-entry toc-h1">
266
+ <a href="#h1">h1</a>
267
+ <ul>
268
+ <li class="toc-entry toc-h3">
269
+ <a href="#h3">h3</a>
270
+ <ul>
271
+ <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
272
+ </ul>
273
+ </li>
274
+ </ul>
275
+ </li>
276
+ </ul>
277
277
  HTML
278
278
  actual = doc.css('ul.section-nav').to_s
279
279
  assert_equal(expected, actual)
@@ -285,36 +285,36 @@ class TestVariousTocHtml < Minitest::Test
285
285
  assert_includes(html, '<h2>h2</h2>')
286
286
  end
287
287
 
288
- TEST_HTML_IGNORE_2 = <<-HTML
289
- <h1>h1</h1>
290
- <div class="exclude">
291
- <h2>h2</h2>
292
- </div>
293
- <h3>h3</h3>
294
- <div class="exclude">
295
- <h4>h4</h4>
296
- <h5>h5</h5>
297
- </div>
298
- <h6>h6</h6>
288
+ TEST_HTML_IGNORE_2 = <<~HTML
289
+ <h1>h1</h1>
290
+ <div class="exclude">
291
+ <h2>h2</h2>
292
+ </div>
293
+ <h3>h3</h3>
294
+ <div class="exclude">
295
+ <h4>h4</h4>
296
+ <h5>h5</h5>
297
+ </div>
298
+ <h6>h6</h6>
299
299
  HTML
300
300
 
301
301
  def test_nested_toc_with_no_toc_section_class_option
302
302
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_IGNORE_2, { 'no_toc_section_class' => 'exclude' })
303
303
  doc = Nokogiri::HTML(parser.toc)
304
- expected = <<-HTML
305
- <ul class="section-nav">
306
- <li class="toc-entry toc-h1">
307
- <a href="#h1">h1</a>
308
- <ul>
309
- <li class="toc-entry toc-h3">
310
- <a href="#h3">h3</a>
311
- <ul>
312
- <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
313
- </ul>
314
- </li>
315
- </ul>
316
- </li>
317
- </ul>
304
+ expected = <<~HTML
305
+ <ul class="section-nav">
306
+ <li class="toc-entry toc-h1">
307
+ <a href="#h1">h1</a>
308
+ <ul>
309
+ <li class="toc-entry toc-h3">
310
+ <a href="#h3">h3</a>
311
+ <ul>
312
+ <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
313
+ </ul>
314
+ </li>
315
+ </ul>
316
+ </li>
317
+ </ul>
318
318
  HTML
319
319
  actual = doc.css('ul.section-nav').to_s
320
320
  assert_equal(expected, actual)
@@ -328,21 +328,21 @@ class TestVariousTocHtml < Minitest::Test
328
328
  assert_includes(html, '<h5>h5</h5>')
329
329
  end
330
330
 
331
- TEST_EXPLICIT_ID = <<-HTML
332
- <h1>h1</h1>
333
- <h1 id="second">h2</h1>
334
- <h1 id="third">h3</h1>
331
+ TEST_EXPLICIT_ID = <<~HTML
332
+ <h1>h1</h1>
333
+ <h1 id="second">h2</h1>
334
+ <h1 id="third">h3</h1>
335
335
  HTML
336
336
 
337
337
  def test_toc_with_explicit_id
338
338
  parser = Jekyll::TableOfContents::Parser.new(TEST_EXPLICIT_ID)
339
339
  doc = Nokogiri::HTML(parser.toc)
340
- expected = <<-HTML
341
- <ul class="section-nav">
342
- <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
343
- <li class="toc-entry toc-h1"><a href="#second">h2</a></li>
344
- <li class="toc-entry toc-h1"><a href="#third">h3</a></li>
345
- </ul>
340
+ expected = <<~HTML
341
+ <ul class="section-nav">
342
+ <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
343
+ <li class="toc-entry toc-h1"><a href="#second">h2</a></li>
344
+ <li class="toc-entry toc-h1"><a href="#third">h3</a></li>
345
+ </ul>
346
346
  HTML
347
347
  actual = doc.css('ul.section-nav').to_s
348
348
  assert_equal(expected, actual)
@@ -352,26 +352,29 @@ class TestVariousTocHtml < Minitest::Test
352
352
  assert_includes(html, %(<a id="second" class="anchor" href="#second" aria-hidden="true">))
353
353
  assert_includes(html, %(<a id="third" class="anchor" href="#third" aria-hidden="true">))
354
354
  end
355
- end
356
355
 
357
- def test_custom_css_classes
358
- parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1, { "item_class" => "custom-item", "list_class" => "custom-list", "sublist_class" => "custom-sublist", "item_prefix" => "custom-prefix-" })
359
- doc = Nokogiri::HTML(parser.toc)
360
- expected = <<-HTML
361
- <ul class="custom-list">
362
- <li class="custom-item custom-prefix-h1">
363
- <a href="#h1">h1</a>
364
- <ul class="custom-sublist">
365
- <li class="custom-item custom-prefix-h3">
366
- <a href="#h3">h3</a>
367
- <ul class="custom-sublist">
368
- <li class="custom-item custom-prefix-h6"><a href="#h6">h6</a></li>
369
- </ul>
370
- </li>
371
- </ul>
372
- </li>
373
- </ul>
374
- HTML
356
+ def test_custom_css_classes
357
+ parser = Jekyll::TableOfContents::Parser.new(
358
+ TEST_HTML_1,
359
+ { 'item_class' => 'custom-item', 'list_class' => 'custom-list', 'sublist_class' => 'custom-sublist', 'item_prefix' => 'custom-prefix-' }
360
+ )
361
+ doc = Nokogiri::HTML(parser.toc)
362
+ expected = <<~HTML
363
+ <ul class="custom-list">
364
+ <li class="custom-item custom-prefix-h1">
365
+ <a href="#h1">h1</a>
366
+ <ul class="custom-sublist">
367
+ <li class="custom-item custom-prefix-h3">
368
+ <a href="#h3">h3</a>
369
+ <ul class="custom-sublist">
370
+ <li class="custom-item custom-prefix-h6"><a href="#h6">h6</a></li>
371
+ </ul>
372
+ </li>
373
+ </ul>
374
+ </li>
375
+ </ul>
376
+ HTML
375
377
 
376
- assert_equal(expected, doc.css('ul.custom-list').to_s)
378
+ assert_equal(expected, doc.css('ul.custom-list').to_s)
379
+ end
377
380
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-toc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.beta1
4
+ version: 0.9.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - toshimaru
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-18 00:00:00.000000000 Z
12
+ date: 2018-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.7'
20
+ version: '1.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: '1.7'
27
+ version: '1.8'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: appraisal
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
+ - ".rubocop.yml"
119
120
  - ".travis.yml"
120
121
  - Appraisals
121
122
  - CHANGELOG.md
@@ -150,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
152
  - - ">="
152
153
  - !ruby/object:Gem::Version
153
- version: 2.2.2
154
+ version: '2.3'
154
155
  required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  requirements:
156
157
  - - ">"
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  version: 1.3.1
159
160
  requirements: []
160
161
  rubyforge_project:
161
- rubygems_version: 2.7.6
162
+ rubygems_version: 2.5.2.3
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: Jekyll Table of Contents plugin