jekyll-toc 0.8.0.beta1 → 0.8.0.beta2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: d596d99053aad35a05c81278de0edfad519bd76727ff60d9b01b70e71008e987
4
- data.tar.gz: 331da3befd626489ff0a39d9d70837abbd902bf8cb17548b219b10e7e24b876a
2
+ SHA1:
3
+ metadata.gz: b22b1a38ade3692df275b45f909d15c6c08c86a9
4
+ data.tar.gz: 10c79cce93cbdfe9c1f563b89357aa4b22f5e95c
5
5
  SHA512:
6
- metadata.gz: ec2c4e4cba02a4205b05249997746a4acab870876e89368b54f601e0082908e42ea3e08098483b3e12b0eb691cbf24a60da81c86db8717525336486d1deb083c
7
- data.tar.gz: 577d24958e189a1f69feafb48e8f1a937cfdbb966ba5186773fe693641bd958575145186dc7d5e7d13be26b633437a06146d9c73c179c46ecbc5065568a57e7e
6
+ metadata.gz: 4cf2f7ece01ba18e9c3df914974f395e1f9133da89380e73bf5cad9d82e20b2dcdd81b6f813854cc0dead5af0f79e72924f200b8cf5fc66bc48023b56859ecb5
7
+ data.tar.gz: 2bf2aa4519199fd01957562b769f14fe22ff0586d5a44c61a8e33180716508b1274967ffe37766e7d1fb63ec47876b82cd1b36d2d64d7b46a69358315fd0c783
@@ -50,9 +50,14 @@ module Jekyll
50
50
  # TODO: Use kramdown auto ids
51
51
  @doc.css(toc_headings).reject { |n| n.classes.include?('no_toc') }.each do |node|
52
52
  text = node.text
53
- id = text.downcase
54
- id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation
55
- id.tr!(' ', '-') # replace spaces with dash
53
+ id = if node.attribute('id')
54
+ node.attribute('id')
55
+ else
56
+ text
57
+ .downcase
58
+ .gsub(PUNCTUATION_REGEXP, '') # remove punctuation
59
+ .tr(' ', '-') # replace spaces with dash
60
+ end
56
61
 
57
62
  uniq = headers[id] > 0 ? "-#{headers[id]}" : ''
58
63
  headers[id] += 1
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JekyllToc
2
- VERSION = '0.8.0.beta1'.freeze
2
+ VERSION = '0.8.0.beta2'.freeze
3
3
  end
@@ -283,4 +283,24 @@ HTML
283
283
 
284
284
  assert_equal(expected, actual)
285
285
  end
286
+
287
+ TEST_EXPLICIT_ID = <<-HTML
288
+ <h1>h1</h1>
289
+ <h1 id="second">h2</h1>
290
+ <h1 id="third">h3</h1>
291
+ HTML
292
+
293
+ def test_toc_with_explicit_id
294
+ parser = Jekyll::TableOfContents::Parser.new(TEST_EXPLICIT_ID, { "ignore_within" => '.exclude'})
295
+ doc = Nokogiri::HTML(parser.toc)
296
+ expected = <<-HTML
297
+ <ul class="section-nav">
298
+ <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
299
+ <li class="toc-entry toc-h1"><a href="#second">h2</a></li>
300
+ <li class="toc-entry toc-h1"><a href="#third">h3</a></li>
301
+ </ul>
302
+ HTML
303
+
304
+ assert_equal(expected, doc.css('ul.section-nav').to_s)
305
+ end
286
306
  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.8.0.beta1
4
+ version: 0.8.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-09 00:00:00.000000000 Z
12
+ date: 2018-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: 1.3.1
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.7.6
161
+ rubygems_version: 2.5.2.3
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Jekyll Table of Contents plugin