jekyll-toc 0.15.0.rc → 0.15.0

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: e250bc0a38525c4496ba464685b2ca3bc9c462953ce7c299a52cf52611940099
4
+ data.tar.gz: 628f832e2adaae7b8b225423149b6dd950d04c884698f1b8e42c6e3990f33359
5
5
  SHA512:
6
- metadata.gz: 44021a6c5bf17fa105b698571d43715aa381297b47355f4f439179063f695318f8071a8c1120318682c9eb25c17d7067fcacfdfc0ea5ce62995428f3e2f3649f
7
- data.tar.gz: 69af07e31563443aa18492717b820aa3d274cc2e1cbb520a9b1489b87c72492ef3611fb96a25403565ea9e809161cffb2809aaead154b047984dac67da268bcb
6
+ metadata.gz: 258fde765cb95ce75abd2b87a4336a3a58630188e872c337014b8b780ac06843521b49070a201a3c9cdc7530409f61caeb159b770801b580eed8fb4921a5f74c
7
+ data.tar.gz: d9d8e1dc2b78c353333db1af1ad03eb86b387e35e89fea8fd554c834e3b8d93b200539f48f9bc070d95bb24f18addb8127329b966a6512ef6bac02909ce37ef1
@@ -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
@@ -21,7 +21,7 @@ jobs:
21
21
  steps:
22
22
  - uses: actions/checkout@v2
23
23
  - name: Set up Ruby ${{ matrix.ruby }}
24
- uses: eregon/use-ruby-action@master
24
+ uses: actions/setup-ruby@v1
25
25
  with:
26
26
  ruby-version: ${{ matrix.ruby }}
27
27
  - name: bundle install
@@ -10,12 +10,12 @@ jobs:
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: actions/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.4
19
19
  env:
20
20
  CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
21
21
  with:
@@ -10,7 +10,7 @@ jobs:
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: actions/setup-ruby@v1
14
14
  with:
15
15
  ruby-version: ${{ matrix.ruby }}
16
16
  - name: bundle install
@@ -1,11 +1,15 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.4
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/Gemfile CHANGED
@@ -7,5 +7,7 @@ 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'
11
13
  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
22
  - [Custom CSS Class](#custom-css-class)
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,7 +118,7 @@ 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
124
  <ul class="section-nav">
@@ -141,9 +144,14 @@ 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
@@ -155,39 +163,49 @@ toc:
155
163
  item_prefix: toc-
156
164
  ```
157
165
 
158
- ## Customization
159
-
160
166
  ### TOC levels
161
167
 
162
- The toc levels can be configured on `_config.yml`:
163
-
164
168
  ```yml
169
+ # _config.yml
165
170
  toc:
166
171
  min_level: 2 # default: 1
167
172
  max_level: 5 # default: 6
168
173
  ```
169
174
 
170
- The default level range is `<h1>` to `<h6>`.
175
+ The default heading range is from `<h1>` to `<h6>`.
176
+
177
+ ### Enable TOC by default
178
+
179
+ You can enable TOC by default with [Front Matter Defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/):
180
+
181
+ ```yml
182
+ # _config.yml
183
+ defaults:
184
+ - scope:
185
+ path: ""
186
+ values:
187
+ toc: true
188
+ ```
171
189
 
172
190
  ### Skip TOC
173
191
 
174
- The heading is ignored in the toc when you add `no_toc` to the class.
192
+ The heading is ignored in the toc by adding `no_toc` class.
175
193
 
176
194
  ```html
177
195
  <h1>h1</h1>
178
- <h1 class="no_toc">This heading is ignored in the toc</h1>
196
+ <h1 class="no_toc">This heading is ignored in the TOC</h1>
179
197
  <h2>h2</h2>
180
198
  ```
181
199
 
182
- ### Skip TOC Section
200
+ ### Skip TOC Sectionally
183
201
 
184
202
  The headings are ignored inside the element which has `no_toc_section` class.
185
203
 
186
204
  ```html
187
205
  <h1>h1</h1>
188
206
  <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>
207
+ <h2>This heading is ignored in the TOC</h2>
208
+ <h3>This heading is ignored in the TOC</h3>
191
209
  </div>
192
210
  <h4>h4</h4>
193
211
  ```
@@ -197,13 +215,15 @@ Which would result in only the `<h1>` & `<h4>` within the example being included
197
215
  The class can be configured on `_config.yml`:
198
216
 
199
217
  ```yml
218
+ # _config.yml
200
219
  toc:
201
220
  no_toc_section_class: exclude # default: no_toc_section
202
221
  ```
203
222
 
204
- Configuring multiple classes for `no_toc_section_class` is allowed:
223
+ Configuring multiple classes are allowed:
205
224
 
206
225
  ```yml
226
+ # _config.yml
207
227
  toc:
208
228
  no_toc_section_class:
209
229
  - no_toc_section
@@ -229,14 +249,15 @@ The toc can be modified with CSS. The sample CSS is the following.
229
249
 
230
250
  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
251
 
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`.
252
+ 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.
253
+ For example, the TOC entry linking to a heading `<h1>...</h1>` (a single `#` in Markdown) will get the CSS class `toc-h1`.
234
254
 
235
255
  ### Custom CSS Class
236
256
 
237
257
  You can apply custom CSS classes to the generated `<ul>` and `<li>` tags.
238
258
 
239
259
  ```yml
260
+ # _config.yml
240
261
  toc:
241
262
  # Default is "section-nav":
242
263
  list_class: my-list-class
@@ -254,6 +275,7 @@ By default the table of contents will be generated as an unordered list via `<ul
254
275
  This can be configured in `_config.yml`:
255
276
 
256
277
  ```yml
278
+ # _config.yml
257
279
  toc:
258
280
  ordered_list: true # default is false
259
281
  ```
@@ -264,6 +286,7 @@ Add a class to the `sublist_class` configuration to append it to the `ol` tags s
264
286
  Example
265
287
 
266
288
  ```yml
289
+ # _config.yml
267
290
  toc:
268
291
  ordered_list: true
269
292
  list_class: my-list-class
@@ -283,3 +306,10 @@ toc:
283
306
  This will produce:
284
307
 
285
308
  ![screenshot](https://user-images.githubusercontent.com/7675276/85813980-a0ea5a80-b719-11ea-9458-ccf9b86a778b.png)
309
+
310
+ ## Alternative Tools
311
+
312
+ - Adding anchor to headings
313
+ - [AnchorJS](https://www.bryanbraun.com/anchorjs/)
314
+ - Generating TOC for kramdown content
315
+ - [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))
@@ -8,13 +8,13 @@ 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
20
  spec.required_ruby_version = '>= 2.4'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module TableOfContents
5
- VERSION = '0.15.0.rc'
5
+ VERSION = '0.15.0'
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 class="section-nav">))
22
22
  end
23
23
  end
@@ -8,19 +8,19 @@ 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
@@ -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
@@ -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 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
@@ -6,24 +6,24 @@ 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('section-nav', configuration.list_class)
13
+ assert_equal('', configuration.sublist_class)
14
+ assert_equal('toc-entry', configuration.item_class)
15
+ assert_equal('toc-', configuration.item_prefix)
16
16
  end
17
17
 
18
18
  def test_type_error
19
19
  configuration = Jekyll::TableOfContents::Configuration.new('TypeError!')
20
20
 
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-'
21
+ assert_equal(1..6, configuration.toc_levels)
22
+ refute(configuration.ordered_list)
23
+ assert_equal('no_toc_section', configuration.no_toc_section_class)
24
+ assert_equal('section-nav', configuration.list_class)
25
+ assert_equal('', configuration.sublist_class)
26
+ assert_equal('toc-entry', configuration.item_class)
27
+ assert_equal('toc-', configuration.item_prefix)
28
28
  end
29
29
  end
@@ -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 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.15.0
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: 2020-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -39,13 +39,14 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.10'
42
- description: Jekyll (Ruby static website generator) plugin which generates a table
43
- of contents.
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"
@@ -93,9 +94,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
94
  version: '2.4'
94
95
  required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  requirements:
96
- - - ">"
97
+ - - ">="
97
98
  - !ruby/object:Gem::Version
98
- version: 1.3.1
99
+ version: '0'
99
100
  requirements: []
100
101
  rubygems_version: 3.1.4
101
102
  signing_key: