jekyll-toc 0.8.0.beta1 → 0.8.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/table_of_contents/parser.rb +8 -3
- data/lib/version.rb +1 -1
- data/test/test_various_toc_html.rb +20 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b22b1a38ade3692df275b45f909d15c6c08c86a9
|
4
|
+
data.tar.gz: 10c79cce93cbdfe9c1f563b89357aa4b22f5e95c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
54
|
-
|
55
|
-
|
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
@@ -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.
|
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-
|
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.
|
161
|
+
rubygems_version: 2.5.2.3
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Jekyll Table of Contents plugin
|