jekyll-toc 0.15.0.rc → 0.17.1

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
2
  SHA256:
3
- metadata.gz: 3d791df4c69353cee2810d445dc565746e9d4ed2f7f738e205f6ee2fef19d369
4
- data.tar.gz: '084bc15ad6fe3fb08b2ad83e979e08d93ffb988adbccc6c7981479cd210d9de4'
3
+ metadata.gz: f104b77b718e1f5f1947d68afae1d18c7ad1c741c14df44b3e52f889cb2100eb
4
+ data.tar.gz: 1a48474b9d6c4d8fd87dc2b81fdf7335e10e1df7da9fb15a4e15f7629697a51a
5
5
  SHA512:
6
- metadata.gz: 44021a6c5bf17fa105b698571d43715aa381297b47355f4f439179063f695318f8071a8c1120318682c9eb25c17d7067fcacfdfc0ea5ce62995428f3e2f3649f
7
- data.tar.gz: 69af07e31563443aa18492717b820aa3d274cc2e1cbb520a9b1489b87c72492ef3611fb96a25403565ea9e809161cffb2809aaead154b047984dac67da268bcb
6
+ metadata.gz: '09f70b02a681ec9237a05fa1e6613ecb2bea4911e5f53e4ded034ac930d689d61ec2f0df325dd080d66d810b10539d2ae3fc015e9b68dba7a67e7fd06573ce73'
7
+ data.tar.gz: 89649e97c2b4640c4787cb2c546a18d3a86303b4a2a08594c95f2c43c7a75bca00ca57029e534b537c2d6861ea8e274e735f75f79bf528ebf026e54c601c73a9
@@ -0,0 +1,19 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ reviewers:
13
+ - toshimaru
14
+ - package-ecosystem: "github-actions"
15
+ directory: "/"
16
+ schedule:
17
+ interval: "weekly"
18
+ reviewers:
19
+ - toshimaru
@@ -4,24 +4,19 @@ jobs:
4
4
  build:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.4, 2.5, 2.6, 2.7]
7
+ ruby: [2.5, 2.6, 2.7, 3.0]
8
8
  gemfile:
9
- - gemfiles/jekyll_3.8.gemfile
10
9
  - gemfiles/jekyll_3.9.gemfile
11
10
  - gemfiles/jekyll_4.0.gemfile
12
11
  - gemfiles/jekyll_4.1.gemfile
13
- exclude:
14
- - ruby: 2.4
15
- gemfile: gemfiles/jekyll_4.0.gemfile
16
- - ruby: 2.4
17
- gemfile: gemfiles/jekyll_4.1.gemfile
12
+ - gemfiles/jekyll_4.2.gemfile
18
13
  env:
19
14
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
20
15
  runs-on: ubuntu-latest
21
16
  steps:
22
17
  - uses: actions/checkout@v2
23
18
  - name: Set up Ruby ${{ matrix.ruby }}
24
- uses: eregon/use-ruby-action@master
19
+ uses: ruby/setup-ruby@v1
25
20
  with:
26
21
  ruby-version: ${{ matrix.ruby }}
27
22
  - name: bundle install
@@ -4,18 +4,18 @@ jobs:
4
4
  build:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.6]
7
+ ruby: [3.0]
8
8
  runs-on: ubuntu-latest
9
9
  name: coverage
10
10
  steps:
11
11
  - uses: actions/checkout@v2
12
12
  - name: Set up Ruby ${{ matrix.ruby }}
13
- uses: eregon/use-ruby-action@master
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
15
  ruby-version: ${{ matrix.ruby }}
16
16
  - name: bundle install
17
17
  run: bundle install --jobs 4 --retry 3
18
- - uses: paambaati/codeclimate-action@v2.4.0
18
+ - uses: paambaati/codeclimate-action@v2.7.5
19
19
  env:
20
20
  CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
21
21
  with:
@@ -4,13 +4,13 @@ jobs:
4
4
  build:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.6]
7
+ ruby: [3.0]
8
8
  runs-on: ubuntu-latest
9
9
  name: rubocop
10
10
  steps:
11
11
  - uses: actions/checkout@v2
12
12
  - name: Set up Ruby ${{ matrix.ruby }}
13
- uses: eregon/use-ruby-action@master
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
15
  ruby-version: ${{ matrix.ruby }}
16
16
  - name: bundle install
data/.rubocop.yml CHANGED
@@ -1,11 +1,15 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
3
4
  Exclude:
4
5
  - "*.gemspec"
5
6
  - "gemfiles/*"
6
7
  - "vendor/**/*"
7
8
  - Rakefile
8
9
  - Gemfile
10
+ require:
11
+ - rubocop-performance
12
+ - rubocop-minitest
9
13
 
10
14
  Metrics/MethodLength:
11
15
  Enabled: false
data/Appraisals CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- SUPPORTED_VERSIONS = %w[3.8 3.9 4.0 4.1].freeze
3
+ SUPPORTED_VERSIONS = %w[3.8 3.9 4.0 4.1 4.2].freeze
4
4
 
5
5
  SUPPORTED_VERSIONS.each do |version|
6
6
  appraise "jekyll-#{version}" do
data/Gemfile CHANGED
@@ -7,5 +7,8 @@ gem 'minitest-reporters'
7
7
  gem 'minitest'
8
8
  gem 'pry'
9
9
  gem 'rake'
10
- gem 'rubocop', '~> 0.81'
10
+ gem 'rubocop-minitest'
11
+ gem 'rubocop-performance'
12
+ gem 'rubocop-rake'
13
+ gem 'rubocop'
11
14
  gem 'simplecov', '~> 0.17.1'
data/README.md CHANGED
@@ -9,17 +9,19 @@
9
9
 
10
10
  - [Installation](#installation)
11
11
  - [Usage](#usage)
12
- - [1. Basic Usage](#1-basic-usage)
13
- - [2. Advanced Usage](#2-advanced-usage)
12
+ - [Basic Usage](#basic-usage)
13
+ - [Advanced Usage](#advanced-usage)
14
14
  - [Generated HTML](#generated-html)
15
- - [Default Configuration](#default-configuration)
16
15
  - [Customization](#customization)
16
+ - [Default Configuration](#default-configuration)
17
17
  - [TOC levels](#toc-levels)
18
+ - [Enable TOC by default](#enable-toc-by-default)
18
19
  - [Skip TOC](#skip-toc)
19
- - [Skip TOC Section](#skip-toc-section)
20
+ - [Skip TOC Sectionally](#skip-toc-sectionally)
20
21
  - [CSS Styling](#css-styling)
21
- - [Custom CSS Class](#custom-css-class)
22
+ - [Custom CSS Class and ID](#custom-css-class-and-id)
22
23
  - [Using Unordered/Ordered lists](#using-unorderedordered-lists)
24
+ - [Alternative Tools](#alternative-tools)
23
25
 
24
26
  ## Installation
25
27
 
@@ -51,7 +53,7 @@ toc: true
51
53
  There are three Liquid filters, which can be applied to HTML content,
52
54
  e.g. the Liquid variable `content` available in Jekyll's templates.
53
55
 
54
- ### 1. Basic Usage
56
+ ### Basic Usage
55
57
 
56
58
  #### `toc` filter
57
59
 
@@ -63,11 +65,11 @@ Add the `toc` filter to your site's `{{ content }}` (e.g. `_layouts/post.html`).
63
65
 
64
66
  This filter places the TOC directly above the content.
65
67
 
66
- ### 2. Advanced Usage
68
+ ### Advanced Usage
67
69
 
68
70
  If you'd like separated TOC and content, you can use `{% toc %}` tag (or `toc_only` filter) and `inject_anchors` filter.
69
71
 
70
- #### `{% toc %}` tag
72
+ #### `{% toc %}` tag / `toc_only` filter
71
73
 
72
74
  Generates the TOC itself as described [below](#generated-html).
73
75
  Mostly useful in cases where the TOC should _not_ be placed immediately
@@ -86,7 +88,8 @@ above the content but at some other place of the page, i.e. an aside.
86
88
 
87
89
  :warning: **`{% toc %}` Tag Limitation**
88
90
 
89
- `{% toc %}` can be available only in [Jekyll Posts](https://jekyllrb.com/docs/step-by-step/08-blogging/) and [Jekyll Collections](https://jekyllrb.com/docs/collections/). If you'd like to use `{% toc %}` except posts or collections, please use `toc_only` filter as described below.
91
+ `{% toc %}` works only for [Jekyll Posts](https://jekyllrb.com/docs/step-by-step/08-blogging/) and [Jekyll Collections](https://jekyllrb.com/docs/collections/).
92
+ If you'd like to use `{% toc %}` except posts or collections, please use `toc_only` filter as described below.
90
93
 
91
94
  ```html
92
95
  <div>
@@ -115,10 +118,10 @@ location with the `toc_only` filter.
115
118
 
116
119
  ## Generated HTML
117
120
 
118
- jekyll-toc generates an unordered list. The HTML output is as follows.
121
+ jekyll-toc generates an unordered list by default. The HTML output is as follows.
119
122
 
120
123
  ```html
121
- <ul class="section-nav">
124
+ <ul id="toc" class="section-nav">
122
125
  <li class="toc-entry toc-h1"><a href="#heading1">Heading.1</a>
123
126
  <ul>
124
127
  <li class="toc-entry toc-h2"><a href="#heading1-1">Heading.1-1</a></li>
@@ -141,53 +144,69 @@ jekyll-toc generates an unordered list. The HTML output is as follows.
141
144
 
142
145
  ![screenshot](https://user-images.githubusercontent.com/803398/28401295-0dcfb7ca-6d54-11e7-892b-2f2e6ca755a7.png)
143
146
 
144
- ## Default Configuration
147
+ ## Customization
148
+
149
+ jekyll-toc is customizable on `_config.yml`.
150
+
151
+ ### Default Configuration
145
152
 
146
153
  ```yml
154
+ # _config.yml
147
155
  toc:
148
156
  min_level: 1
149
157
  max_level: 6
150
158
  ordered_list: false
151
159
  no_toc_section_class: no_toc_section
160
+ list_id: toc
152
161
  list_class: section-nav
153
162
  sublist_class: ''
154
163
  item_class: toc-entry
155
164
  item_prefix: toc-
156
165
  ```
157
166
 
158
- ## Customization
159
-
160
167
  ### TOC levels
161
168
 
162
- The toc levels can be configured on `_config.yml`:
163
-
164
169
  ```yml
170
+ # _config.yml
165
171
  toc:
166
172
  min_level: 2 # default: 1
167
173
  max_level: 5 # default: 6
168
174
  ```
169
175
 
170
- The default level range is `<h1>` to `<h6>`.
176
+ The default heading range is from `<h1>` to `<h6>`.
177
+
178
+ ### Enable TOC by default
179
+
180
+ You can enable TOC by default with [Front Matter Defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/):
181
+
182
+ ```yml
183
+ # _config.yml
184
+ defaults:
185
+ - scope:
186
+ path: ""
187
+ values:
188
+ toc: true
189
+ ```
171
190
 
172
191
  ### Skip TOC
173
192
 
174
- The heading is ignored in the toc when you add `no_toc` to the class.
193
+ The heading is ignored in the toc by adding `no_toc` class.
175
194
 
176
195
  ```html
177
196
  <h1>h1</h1>
178
- <h1 class="no_toc">This heading is ignored in the toc</h1>
197
+ <h1 class="no_toc">This heading is ignored in the TOC</h1>
179
198
  <h2>h2</h2>
180
199
  ```
181
200
 
182
- ### Skip TOC Section
201
+ ### Skip TOC Sectionally
183
202
 
184
203
  The headings are ignored inside the element which has `no_toc_section` class.
185
204
 
186
205
  ```html
187
206
  <h1>h1</h1>
188
207
  <div class="no_toc_section">
189
- <h2>This heading is ignored in the toc</h2>
190
- <h3>This heading is ignored in the toc</h3>
208
+ <h2>This heading is ignored in the TOC</h2>
209
+ <h3>This heading is ignored in the TOC</h3>
191
210
  </div>
192
211
  <h4>h4</h4>
193
212
  ```
@@ -197,13 +216,15 @@ Which would result in only the `<h1>` & `<h4>` within the example being included
197
216
  The class can be configured on `_config.yml`:
198
217
 
199
218
  ```yml
219
+ # _config.yml
200
220
  toc:
201
221
  no_toc_section_class: exclude # default: no_toc_section
202
222
  ```
203
223
 
204
- Configuring multiple classes for `no_toc_section_class` is allowed:
224
+ Configuring multiple classes are allowed:
205
225
 
206
226
  ```yml
227
+ # _config.yml
207
228
  toc:
208
229
  no_toc_section_class:
209
230
  - no_toc_section
@@ -229,23 +250,21 @@ The toc can be modified with CSS. The sample CSS is the following.
229
250
 
230
251
  Each TOC `li` entry has two CSS classes for further styling. The general `toc-entry` is applied to all `li` elements in the `ul.section-nav`.
231
252
 
232
- Depending on the heading level each specific entry refers to, it has a second CSS class `toc-XX`, where `XX` is the HTML heading tag name. For example, the TOC entry linking to a heading `<h1>...</h1>` (a single
233
- `#` in Markdown) will get the CSS class `toc-h1`.
253
+ Depending on the heading level each specific entry refers to, it has a second CSS class `toc-XX`, where `XX` is the HTML heading tag name.
254
+ For example, the TOC entry linking to a heading `<h1>...</h1>` (a single `#` in Markdown) will get the CSS class `toc-h1`.
234
255
 
235
- ### Custom CSS Class
256
+ ### Custom CSS Class and ID
236
257
 
237
258
  You can apply custom CSS classes to the generated `<ul>` and `<li>` tags.
238
259
 
239
260
  ```yml
261
+ # _config.yml
240
262
  toc:
241
- # Default is "section-nav":
242
- list_class: my-list-class
243
- # Default is no class for sublists:
244
- sublist_class: my-sublist-class
245
- # Default is "toc-entry":
246
- item_class: my-item-class
247
- # Default is "toc-":
248
- item_prefix: item-
263
+ list_id: my-toc-id # Default: "toc"
264
+ list_class: my-list-class # Default: "section-nav"
265
+ sublist_class: my-sublist-class # Default: no class for sublists
266
+ item_class: my-item-class # Default: "toc-entry"
267
+ item_prefix: item- # Default: "toc-":
249
268
  ```
250
269
 
251
270
  ### Using Unordered/Ordered lists
@@ -254,6 +273,7 @@ By default the table of contents will be generated as an unordered list via `<ul
254
273
  This can be configured in `_config.yml`:
255
274
 
256
275
  ```yml
276
+ # _config.yml
257
277
  toc:
258
278
  ordered_list: true # default is false
259
279
  ```
@@ -264,6 +284,7 @@ Add a class to the `sublist_class` configuration to append it to the `ol` tags s
264
284
  Example
265
285
 
266
286
  ```yml
287
+ # _config.yml
267
288
  toc:
268
289
  ordered_list: true
269
290
  list_class: my-list-class
@@ -283,3 +304,10 @@ toc:
283
304
  This will produce:
284
305
 
285
306
  ![screenshot](https://user-images.githubusercontent.com/7675276/85813980-a0ea5a80-b719-11ea-9458-ccf9b86a778b.png)
307
+
308
+ ## Alternative Tools
309
+
310
+ - Adding anchor to headings
311
+ - [AnchorJS](https://www.bryanbraun.com/anchorjs/)
312
+ - Generating TOC for kramdown content
313
+ - [Automatic “Table of Contents” Generation](https://kramdown.gettalong.org/converter/html.html#toc) (See also. [Create Table of Contents in kramdown](https://blog.toshima.ru/2020/05/22/kramdown-toc))
@@ -7,7 +7,10 @@ gem "minitest-reporters"
7
7
  gem "minitest"
8
8
  gem "pry"
9
9
  gem "rake"
10
- gem "rubocop", "~> 0.81"
10
+ gem "rubocop-minitest"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rake"
13
+ gem "rubocop"
11
14
  gem "simplecov", "~> 0.17.1"
12
15
  gem "jekyll", "3.8"
13
16
 
@@ -7,7 +7,10 @@ gem "minitest-reporters"
7
7
  gem "minitest"
8
8
  gem "pry"
9
9
  gem "rake"
10
- gem "rubocop", "~> 0.81"
10
+ gem "rubocop-minitest"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rake"
13
+ gem "rubocop"
11
14
  gem "simplecov", "~> 0.17.1"
12
15
  gem "jekyll", "3.9"
13
16
 
@@ -7,7 +7,10 @@ gem "minitest-reporters"
7
7
  gem "minitest"
8
8
  gem "pry"
9
9
  gem "rake"
10
- gem "rubocop", "~> 0.81"
10
+ gem "rubocop-minitest"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rake"
13
+ gem "rubocop"
11
14
  gem "simplecov", "~> 0.17.1"
12
15
  gem "jekyll", "4.0"
13
16
 
@@ -7,7 +7,10 @@ gem "minitest-reporters"
7
7
  gem "minitest"
8
8
  gem "pry"
9
9
  gem "rake"
10
- gem "rubocop", "~> 0.81"
10
+ gem "rubocop-minitest"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rake"
13
+ gem "rubocop"
11
14
  gem "simplecov", "~> 0.17.1"
12
15
  gem "jekyll", "4.1"
13
16
 
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "minitest-reporters"
7
+ gem "minitest"
8
+ gem "pry"
9
+ gem "rake"
10
+ gem "rubocop-minitest"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rake"
13
+ gem "rubocop"
14
+ gem "simplecov", "~> 0.17.1"
15
+ gem "jekyll", "4.2"
16
+
17
+ gemspec path: "../"
data/jekyll-toc.gemspec CHANGED
@@ -8,17 +8,17 @@ Gem::Specification.new do |spec|
8
8
  spec.name = 'jekyll-toc'
9
9
  spec.version = Jekyll::TableOfContents::VERSION
10
10
  spec.summary = 'Jekyll Table of Contents plugin'
11
- spec.description = 'Jekyll (Ruby static website generator) plugin which generates a table of contents.'
11
+ spec.description = 'Jekyll (Ruby static website generator) plugin which generates a Table of Contents for the page.'
12
12
  spec.authors = %w(toshimaru torbjoernk)
13
13
  spec.email = 'me@toshimaru.net'
14
14
  spec.files = `git ls-files -z`.split("\x0")
15
15
  spec.homepage = 'https://github.com/toshimaru/jekyll-toc'
16
16
  spec.license = 'MIT'
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.required_ruby_version = '>= 2.4'
20
+ spec.required_ruby_version = '>= 2.5'
21
21
 
22
- spec.add_dependency 'jekyll', '>= 3.8'
23
- spec.add_dependency 'nokogiri', '~> 1.10'
22
+ spec.add_dependency 'jekyll', '>= 3.9'
23
+ spec.add_dependency 'nokogiri', '~> 1.11'
24
24
  end
@@ -5,13 +5,14 @@ module Jekyll
5
5
  # jekyll-toc configuration class
6
6
  class Configuration
7
7
  attr_reader :toc_levels, :no_toc_class, :ordered_list, :no_toc_section_class,
8
- :list_class, :sublist_class, :item_class, :item_prefix
8
+ :list_id, :list_class, :sublist_class, :item_class, :item_prefix
9
9
 
10
10
  DEFAULT_CONFIG = {
11
11
  'min_level' => 1,
12
12
  'max_level' => 6,
13
13
  'ordered_list' => false,
14
14
  'no_toc_section_class' => 'no_toc_section',
15
+ 'list_id' => 'toc',
15
16
  'list_class' => 'section-nav',
16
17
  'sublist_class' => '',
17
18
  'item_class' => 'toc-entry',
@@ -25,6 +26,7 @@ module Jekyll
25
26
  @ordered_list = options['ordered_list']
26
27
  @no_toc_class = 'no_toc'
27
28
  @no_toc_section_class = options['no_toc_section_class']
29
+ @list_id = options['list_id']
28
30
  @list_class = options['list_class']
29
31
  @sublist_class = options['sublist_class']
30
32
  @item_class = options['item_class']
@@ -19,7 +19,7 @@ module Jekyll
19
19
  end
20
20
 
21
21
  def build_toc
22
- %(<#{list_tag} class="#{@configuration.list_class}">\n#{build_toc_list(@entries)}</#{list_tag}>)
22
+ %(<#{list_tag} id="#{@configuration.list_id}" class="#{@configuration.list_class}">\n#{build_toc_list(@entries)}</#{list_tag}>)
23
23
  end
24
24
 
25
25
  def inject_anchors_into_html
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module TableOfContents
5
- VERSION = '0.15.0.rc'
5
+ VERSION = '0.17.1'
6
6
  end
7
7
  end
@@ -18,6 +18,6 @@ class TestInjectAnchorsFilter < Minitest::Test
18
18
  def test_does_not_inject_toc
19
19
  html = @parser.inject_anchors_into_html
20
20
 
21
- assert_nil(/<ul class="section-nav">/ =~ html)
21
+ refute_includes(html, %(<ul id="toc" class="section-nav">))
22
22
  end
23
23
  end
@@ -5,7 +5,7 @@ require 'test_helper'
5
5
  class TestInvalidOptions < Minitest::Test
6
6
  BASE_HTML = '<h1>h1</h1>'
7
7
  EXPECTED_HTML = <<~HTML.chomp
8
- <ul class="section-nav">
8
+ <ul id="toc" class="section-nav">
9
9
  <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
10
10
  </ul>
11
11
  HTML
@@ -8,26 +8,26 @@ class TestOrderedList < Minitest::Test
8
8
  def test_default_configuration
9
9
  configuration = Jekyll::TableOfContents::Configuration.new({})
10
10
 
11
- assert_equal configuration.ordered_list, false
11
+ refute(configuration.ordered_list)
12
12
  end
13
13
 
14
14
  def test_disabled_ordered_list
15
15
  configuration = Jekyll::TableOfContents::Configuration.new('ordered_list' => false)
16
16
 
17
- assert_equal configuration.ordered_list, false
17
+ refute(configuration.ordered_list)
18
18
  end
19
19
 
20
20
  def test_enabled_ordered_list
21
21
  configuration = Jekyll::TableOfContents::Configuration.new('ordered_list' => true)
22
22
 
23
- assert_equal configuration.ordered_list, true
23
+ assert(configuration.ordered_list)
24
24
  end
25
25
 
26
26
  def test_basic_ordered_list_top_heading
27
27
  parse_with_ordered_list
28
28
  html = @parser.toc
29
29
 
30
- assert_match(/^<ol class="section-nav">/, html)
30
+ assert_match(/^<ol id="toc" class="section-nav">/, html)
31
31
  end
32
32
 
33
33
  def test_ordered_list_sub_headings
@@ -41,7 +41,7 @@ class TestOrderedList < Minitest::Test
41
41
  parse_with_ordered_list_and_classes
42
42
  html = @parser.toc
43
43
 
44
- assert_match(/^<ol class="top-list-class">/, html)
44
+ assert_match(/^<ol id="toc" class="top-list-class">/, html)
45
45
  end
46
46
 
47
47
  def test_ordered_list_sub_headings_with_classes
@@ -57,7 +57,7 @@ class TestOrderedList < Minitest::Test
57
57
 
58
58
  occurrences = html.scan(/<ol class="sublist-class">/).count
59
59
 
60
- assert_equal occurrences, 5
60
+ assert_equal(5, occurrences)
61
61
  end
62
62
 
63
63
  private
@@ -31,6 +31,6 @@ class TestTOCFilter < Minitest::Test
31
31
  def test_injects_toc_container
32
32
  html = @parser.toc
33
33
 
34
- assert_match(/<ul class="section-nav">/, html)
34
+ assert_match(/<ul id="toc" class="section-nav">/, html)
35
35
  end
36
36
  end
@@ -12,12 +12,12 @@ class TestTOCOnlyFilter < Minitest::Test
12
12
  def test_injects_toc_container
13
13
  html = @parser.build_toc
14
14
 
15
- assert_match(/<ul class="section-nav">/, html)
15
+ assert_includes(html, %(<ul id="toc" class="section-nav">))
16
16
  end
17
17
 
18
18
  def test_does_not_return_content
19
19
  html = @parser.build_toc
20
20
 
21
- assert_nil(%r{<h1>Simple H1</h1>} =~ html)
21
+ refute_includes(html, %(<h1>Simple H1</h1>))
22
22
  end
23
23
  end
@@ -12,7 +12,7 @@ class TestVariousTocHtml < Minitest::Test
12
12
  def test_nested_toc
13
13
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML)
14
14
  expected = <<~HTML.chomp
15
- <ul class="section-nav">
15
+ <ul id="toc" class="section-nav">
16
16
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
17
17
  <ul>
18
18
  <li class="toc-entry toc-h3"><a href="#h3">h3</a>
@@ -31,7 +31,7 @@ class TestVariousTocHtml < Minitest::Test
31
31
  def test_nested_toc_with_min_and_max
32
32
  parser = Jekyll::TableOfContents::Parser.new(TEST_HTML, 'min_level' => 2, 'max_level' => 5)
33
33
  expected = <<~HTML.chomp
34
- <ul class="section-nav">
34
+ <ul id="toc" class="section-nav">
35
35
  <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
36
36
  </ul>
37
37
  HTML
@@ -47,7 +47,7 @@ class TestVariousTocHtml < Minitest::Test
47
47
  <h6>h6</h6>
48
48
  HTML
49
49
  expected = <<~HTML.chomp
50
- <ul class="section-nav">
50
+ <ul id="toc" class="section-nav">
51
51
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
52
52
  <ul>
53
53
  <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
@@ -74,7 +74,7 @@ class TestVariousTocHtml < Minitest::Test
74
74
  <h1>h1</h1>
75
75
  HTML
76
76
  expected = <<~HTML.chomp
77
- <ul class="section-nav">
77
+ <ul id="toc" class="section-nav">
78
78
  <li class="toc-entry toc-h6"><a href="#h6">h6</a></li>
79
79
  <li class="toc-entry toc-h5"><a href="#h5">h5</a></li>
80
80
  <li class="toc-entry toc-h4"><a href="#h4">h4</a></li>
@@ -96,7 +96,7 @@ class TestVariousTocHtml < Minitest::Test
96
96
  <h5>h5</h5>
97
97
  HTML
98
98
  expected = <<~HTML.chomp
99
- <ul class="section-nav">
99
+ <ul id="toc" class="section-nav">
100
100
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
101
101
  <ul>
102
102
  <li class="toc-entry toc-h3"><a href="#h3">h3</a></li>
@@ -129,7 +129,7 @@ class TestVariousTocHtml < Minitest::Test
129
129
  <h4 class="no_toc">no_toc h4</h4>
130
130
  HTML
131
131
  expected = <<~HTML.chomp
132
- <ul class="section-nav">
132
+ <ul id="toc" class="section-nav">
133
133
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
134
134
  <ul>
135
135
  <li class="toc-entry toc-h2"><a href="#h2">h2</a>
@@ -156,7 +156,7 @@ class TestVariousTocHtml < Minitest::Test
156
156
  <h3>う</h3>
157
157
  HTML
158
158
  expected = <<~HTML.chomp
159
- <ul class="section-nav">
159
+ <ul id="toc" class="section-nav">
160
160
  <li class="toc-entry toc-h1"><a href="#%E3%81%82">あ</a>
161
161
  <ul>
162
162
  <li class="toc-entry toc-h2"><a href="#%E3%81%84">い</a>
@@ -184,7 +184,7 @@ class TestVariousTocHtml < Minitest::Test
184
184
  <h1>&amp; &lt; &gt;</h1>
185
185
  HTML
186
186
  expected = <<~HTML.chomp
187
- <ul class="section-nav">
187
+ <ul id="toc" class="section-nav">
188
188
  <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
189
189
  <li class="toc-entry toc-h1"><a href="#base-href">&lt;base href&gt;</a></li>
190
190
  <li class="toc-entry toc-h1"><a href="#--">&amp; &lt; &gt;</a></li>
@@ -200,7 +200,7 @@ class TestVariousTocHtml < Minitest::Test
200
200
  <h2><em>h2</em></h2>
201
201
  HTML
202
202
  expected = <<~HTML.chomp
203
- <ul class="section-nav">
203
+ <ul id="toc" class="section-nav">
204
204
  <li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
205
205
  <li class="toc-entry toc-h2"><a href="#h2-1">h2</a></li>
206
206
  </ul>
@@ -219,7 +219,7 @@ class TestVariousTocHtml < Minitest::Test
219
219
  <h6>h6</h6>
220
220
  HTML
221
221
  expected = <<~HTML.chomp
222
- <ul class="section-nav">
222
+ <ul id="toc" class="section-nav">
223
223
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
224
224
  <ul>
225
225
  <li class="toc-entry toc-h3"><a href="#h3">h3</a>
@@ -254,7 +254,7 @@ class TestVariousTocHtml < Minitest::Test
254
254
  <h6>h6</h6>
255
255
  HTML
256
256
  expected = <<~HTML.chomp
257
- <ul class="section-nav">
257
+ <ul id="toc" class="section-nav">
258
258
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
259
259
  <ul>
260
260
  <li class="toc-entry toc-h3"><a href="#h3">h3</a>
@@ -291,7 +291,7 @@ class TestVariousTocHtml < Minitest::Test
291
291
  <h6>h6</h6>
292
292
  HTML
293
293
  expected = <<~HTML.chomp
294
- <ul class="section-nav">
294
+ <ul id="toc" class="section-nav">
295
295
  <li class="toc-entry toc-h1"><a href="#h1">h1</a>
296
296
  <ul>
297
297
  <li class="toc-entry toc-h3"><a href="#h3">h3</a>
@@ -321,7 +321,7 @@ class TestVariousTocHtml < Minitest::Test
321
321
  <h1 id="third">h3</h1>
322
322
  HTML
323
323
  expected = <<~HTML.chomp
324
- <ul class="section-nav">
324
+ <ul id="toc" class="section-nav">
325
325
  <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
326
326
  <li class="toc-entry toc-h1"><a href="#second">h2</a></li>
327
327
  <li class="toc-entry toc-h1"><a href="#third">h3</a></li>
@@ -342,7 +342,7 @@ class TestVariousTocHtml < Minitest::Test
342
342
  <h1>h1</h1>
343
343
  HTML
344
344
  expected = <<~HTML.chomp
345
- <ul class="section-nav">
345
+ <ul id="toc" class="section-nav">
346
346
  <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
347
347
  <li class="toc-entry toc-h1"><a href="#h1-1">h1</a></li>
348
348
  <li class="toc-entry toc-h1"><a href="#h1-2">h1</a></li>
@@ -355,10 +355,10 @@ class TestVariousTocHtml < Minitest::Test
355
355
  def test_custom_css_classes
356
356
  parser = Jekyll::TableOfContents::Parser.new(
357
357
  TEST_HTML,
358
- 'item_class' => 'custom-item', 'list_class' => 'custom-list', 'sublist_class' => 'custom-sublist', 'item_prefix' => 'custom-prefix-'
358
+ 'item_class' => 'custom-item', 'list_id' => 'custom-toc-id', 'list_class' => 'custom-list', 'sublist_class' => 'custom-sublist', 'item_prefix' => 'custom-prefix-'
359
359
  )
360
360
  expected = <<~HTML.chomp
361
- <ul class="custom-list">
361
+ <ul id="custom-toc-id" class="custom-list">
362
362
  <li class="custom-item custom-prefix-h1"><a href="#h1">h1</a>
363
363
  <ul class="custom-sublist">
364
364
  <li class="custom-item custom-prefix-h3"><a href="#h3">h3</a>
@@ -6,24 +6,26 @@ class TestConfiguration < Minitest::Test
6
6
  def test_default_configuration
7
7
  configuration = Jekyll::TableOfContents::Configuration.new({})
8
8
 
9
- assert_equal configuration.toc_levels, 1..6
10
- assert_equal configuration.ordered_list, false
11
- assert_equal configuration.no_toc_section_class, 'no_toc_section'
12
- assert_equal configuration.list_class, 'section-nav'
13
- assert_equal configuration.sublist_class, ''
14
- assert_equal configuration.item_class, 'toc-entry'
15
- assert_equal configuration.item_prefix, 'toc-'
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)
16
17
  end
17
18
 
18
19
  def test_type_error
19
20
  configuration = Jekyll::TableOfContents::Configuration.new('TypeError!')
20
21
 
21
- assert_equal configuration.toc_levels, 1..6
22
- assert_equal configuration.ordered_list, false
23
- assert_equal configuration.no_toc_section_class, 'no_toc_section'
24
- assert_equal configuration.list_class, 'section-nav'
25
- assert_equal configuration.sublist_class, ''
26
- assert_equal configuration.item_class, 'toc-entry'
27
- assert_equal configuration.item_prefix, 'toc-'
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)
28
30
  end
29
31
  end
@@ -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 "<ul class=\"section-nav\">\n</ul>", toc_only(DUMMY_HTML)
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 "<ul class=\"section-nav\">\n</ul>#{DUMMY_HTML}", toc(DUMMY_HTML)
37
+ assert_equal %(<ul id="toc" class="section-nav">\n</ul>#{DUMMY_HTML}), toc(DUMMY_HTML)
38
38
  end
39
39
 
40
40
  private
@@ -36,7 +36,7 @@ class TestKramdownList < Minitest::Test
36
36
  assert_equal(expected, actual)
37
37
  end
38
38
 
39
- def test_kramdown_list_1
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 test_kramdown_list_2
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 test_kramdown_list_3
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 test_kramdown_list_4
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 test_kramdown_list_5
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 tag.render(context), "<ul class=\"section-nav\">\n<li class=\"toc-entry toc-h1\"><a href=\"#test\">test</a></li>\n</ul>"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-toc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.rc
4
+ version: 0.17.1
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: 2020-10-13 00:00:00.000000000 Z
12
+ date: 2021-05-16 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.8'
20
+ version: '3.9'
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.8'
27
+ version: '3.9'
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.10'
34
+ version: '1.11'
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.10'
42
- description: Jekyll (Ruby static website generator) plugin which generates a table
43
- of contents.
41
+ version: '1.11'
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"
@@ -61,6 +62,7 @@ files:
61
62
  - gemfiles/jekyll_3.9.gemfile
62
63
  - gemfiles/jekyll_4.0.gemfile
63
64
  - gemfiles/jekyll_4.1.gemfile
65
+ - gemfiles/jekyll_4.2.gemfile
64
66
  - jekyll-toc.gemspec
65
67
  - lib/jekyll-toc.rb
66
68
  - lib/table_of_contents/configuration.rb
@@ -90,14 +92,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
92
  requirements:
91
93
  - - ">="
92
94
  - !ruby/object:Gem::Version
93
- version: '2.4'
95
+ version: '2.5'
94
96
  required_rubygems_version: !ruby/object:Gem::Requirement
95
97
  requirements:
96
- - - ">"
98
+ - - ">="
97
99
  - !ruby/object:Gem::Version
98
- version: 1.3.1
100
+ version: '0'
99
101
  requirements: []
100
- rubygems_version: 3.1.4
102
+ rubygems_version: 3.2.15
101
103
  signing_key:
102
104
  specification_version: 4
103
105
  summary: Jekyll Table of Contents plugin