jekyll-toc 0.9.0 → 0.9.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: 3f60a37f7ac53d9e2d667fa4f7cb5f36c875915ae9f7dbda6dad5e104d78fad0
4
- data.tar.gz: 29139c36b99215e07b27297436b16e6aa8eee0f6689b79c967d62fbde4739c5a
3
+ metadata.gz: 705551195e11b692852b8515218169cd4c9c338824817b13591f5427d9921da2
4
+ data.tar.gz: 497a38ad31db5eddca9c7f7723cb65310732ad8dc07946fa08686258b1aa18c4
5
5
  SHA512:
6
- metadata.gz: 9a0a06408311b21cd36b37bd80f6aafe87b8883b3e93d4450a28882d49ed68f8a50c6fea04229520c5eb0795f31f46856ddae1461297a9e39da7d8a8c9285fae
7
- data.tar.gz: 61e0704b9cbe398b4671e4b41a15562586bfedaacbf5dbb01e42695109d91244ac5325514b115f3a1ef54b7299d9b7d8bdb11d9b414dd1ea4cd2b568bcbf5979
6
+ metadata.gz: bfad59fcefb5a35f2c332ba948d16e3db883178eb413cc6729ab2c088e6efdc79c26c8f459b676b7ba9cd8ff27a17cfe637f20c87023187418f22cd9445dbdf9
7
+ data.tar.gz: d6d020c0adc84111b1e9dd4919412b65a5d60d4f913e0eec4fcebc85acdc04c6da9bc535b0d096c9d1a69848553f3fb5f7079e08b8eac5c2c8b6b232c6de5788
data/.rubocop.yml CHANGED
@@ -1,12 +1,13 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.3
3
3
  Exclude:
4
+ - '*.gemspec'
4
5
  - 'gemfiles/*'
6
+ - Rakefile
7
+ - Gemfile
5
8
 
6
9
  Metrics/LineLength:
7
- Max: 100
8
- Exclude:
9
- - 'test/**/*'
10
+ Enabled: false
10
11
 
11
12
  Metrics/MethodLength:
12
13
  Enabled: false
@@ -16,3 +17,7 @@ Metrics/AbcSize:
16
17
 
17
18
  Metrics/ClassLength:
18
19
  Enabled: false
20
+
21
+ Style/FileName:
22
+ Enabled: false
23
+
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ env:
4
+ global:
5
+ - CC_TEST_REPORTER_ID=6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
3
6
  rvm:
4
7
  - 2.3.7
5
8
  - 2.4.4
@@ -10,8 +13,11 @@ gemfile:
10
13
  - gemfiles/jekyll_3.7.gemfile
11
14
  - gemfiles/jekyll_3.6.gemfile
12
15
  - gemfiles/jekyll_3.5.gemfile
13
- addons:
14
- code_climate:
15
- repo_token: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
16
+ before_script:
17
+ # Download cc-test-reporter
18
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
19
+ - chmod +x ./cc-test-reporter
20
+ - ./cc-test-reporter before-build
16
21
  after_success:
22
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
17
23
  - bundle exec codeclimate-test-reporter
data/README.md CHANGED
@@ -144,6 +144,16 @@ toc:
144
144
  no_toc_section_class: exclude # default: no_toc_section
145
145
  ```
146
146
 
147
+ Configuring mutiple classes are allowed:
148
+
149
+ ```yml
150
+ toc:
151
+ no_toc_section_class:
152
+ - no_toc_section
153
+ - exclude
154
+ - your_custom_skip_class_name
155
+ ```
156
+
147
157
  #### TOC levels
148
158
 
149
159
  The toc levels can be configured on `_config.yml`:
data/jekyll-toc.gemspec CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.add_runtime_dependency 'nokogiri', '~> 1.8'
21
21
 
22
22
  spec.add_development_dependency 'appraisal'
23
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
24
23
  spec.add_development_dependency 'jekyll', '>= 3.5'
25
24
  spec.add_development_dependency 'minitest', '~> 5.0'
26
25
  spec.add_development_dependency 'pry'
27
26
  spec.add_development_dependency 'rake'
28
27
  spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'simplecov'
29
29
  end
data/lib/jekyll-toc.rb CHANGED
@@ -13,6 +13,7 @@ module Jekyll
13
13
  # end
14
14
  # end
15
15
 
16
+ # Jekyll Table of Contents filter plugin
16
17
  module TableOfContentsFilter
17
18
  def toc_only(html)
18
19
  return html unless toc_enabled?
@@ -127,7 +127,15 @@ module Jekyll
127
127
  end
128
128
 
129
129
  def toc_headings_in_no_toc_section
130
- @toc_levels.map { |level| ".#{@no_toc_section_class} h#{level}" }.join(',')
130
+ if @no_toc_section_class.is_a? Array
131
+ @no_toc_section_class.map { |cls| toc_headings_within(cls) }.join(',')
132
+ else
133
+ toc_headings_within(@no_toc_section_class)
134
+ end
135
+ end
136
+
137
+ def toc_headings_within(class_name)
138
+ @toc_levels.map { |level| ".#{class_name} h#{level}" }.join(',')
131
139
  end
132
140
 
133
141
  def generate_option_hash(options)
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllToc
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
@@ -86,7 +86,7 @@ class TestVariousTocHtml < Minitest::Test
86
86
  end
87
87
 
88
88
  def test_nested_toc_with_min_and_max
89
- parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1, { 'min_level' => 2, 'max_level' => 5 })
89
+ parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1, 'min_level' => 2, 'max_level' => 5)
90
90
  doc = Nokogiri::HTML(parser.toc)
91
91
  expected = <<~HTML
92
92
  <ul class="section-nav">
@@ -299,7 +299,50 @@ class TestVariousTocHtml < Minitest::Test
299
299
  HTML
300
300
 
301
301
  def test_nested_toc_with_no_toc_section_class_option
302
- parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_IGNORE_2, { 'no_toc_section_class' => 'exclude' })
302
+ parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_IGNORE_2, 'no_toc_section_class' => 'exclude')
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>
318
+ HTML
319
+ actual = doc.css('ul.section-nav').to_s
320
+ assert_equal(expected, actual)
321
+
322
+ html = parser.inject_anchors_into_html
323
+ assert_match(%r{<h1>.+</h1>}m, html)
324
+ assert_match(%r{<h3>.+</h3>}m, html)
325
+ assert_match(%r{<h6>.+</h6>}m, html)
326
+ assert_includes(html, '<h2>h2</h2>')
327
+ assert_includes(html, '<h4>h4</h4>')
328
+ assert_includes(html, '<h5>h5</h5>')
329
+ end
330
+
331
+ TEST_HTML_IGNORE_3 = <<~HTML
332
+ <h1>h1</h1>
333
+ <div class="no_toc_section">
334
+ <h2>h2</h2>
335
+ </div>
336
+ <h3>h3</h3>
337
+ <div class="exclude">
338
+ <h4>h4</h4>
339
+ <h5>h5</h5>
340
+ </div>
341
+ <h6>h6</h6>
342
+ HTML
343
+
344
+ def test_multiple_no_toc_section_classes
345
+ parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_IGNORE_3, 'no_toc_section_class' => ['no_toc_section', 'exclude'])
303
346
  doc = Nokogiri::HTML(parser.toc)
304
347
  expected = <<~HTML
305
348
  <ul class="section-nav">
@@ -356,7 +399,7 @@ class TestVariousTocHtml < Minitest::Test
356
399
  def test_custom_css_classes
357
400
  parser = Jekyll::TableOfContents::Parser.new(
358
401
  TEST_HTML_1,
359
- { 'item_class' => 'custom-item', 'list_class' => 'custom-list', 'sublist_class' => 'custom-sublist', 'item_prefix' => 'custom-prefix-' }
402
+ 'item_class' => 'custom-item', 'list_class' => 'custom-list', 'sublist_class' => 'custom-sublist', 'item_prefix' => 'custom-prefix-'
360
403
  )
361
404
  doc = Nokogiri::HTML(parser.toc)
362
405
  expected = <<~HTML
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
4
+ version: 0.9.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: 2018-10-29 00:00:00.000000000 Z
12
+ date: 2018-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: codeclimate-test-reporter
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '1.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '1.0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: jekyll
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +109,20 @@ dependencies:
123
109
  - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: simplecov
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
126
  description: A liquid filter plugin for Jekyll which generates a table of contents.
127
127
  email: me@toshimaru.net
128
128
  executables: []