jekyll-toc 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/table_of_contents/parser.rb +1 -1
- data/lib/version.rb +1 -1
- data/test/test_various_toc_html.rb +59 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a98fa015f2cd16b45d6ea73f70f520f75270c27e4ca3a79258c817a475c573dc
|
4
|
+
data.tar.gz: a4274d04f1f0fe73d5e02e3f910d91012e21d0bd2911e6af8b78db1850888dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4c08e4c22c891df141d3a12c9a2c46127b07b3afadd5a68cdf81d1f59fd9f17b35c8f8013e461f4a466c1a561539f010ec8433104867c2a6d90397ecd61fbd
|
7
|
+
data.tar.gz: b20a95d26d6435f55d874f740f8c4560cc139ae3b44073fe46911f5289fe7cb9b874642554318b7ad7ad6ba4bcd2471e49d3ef97473d554fba32ce22c1d5f99e
|
data/lib/version.rb
CHANGED
@@ -3,6 +3,35 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class TestVariousTocHtml < Minitest::Test
|
6
|
+
# ref. https://github.com/toshimaru/jekyll-toc/issues/45
|
7
|
+
ANGLE_BRACKET_HTML = <<-HTML
|
8
|
+
<h1>h1</h1>
|
9
|
+
<h1><base href></h1>
|
10
|
+
<h1>& < ></h1>
|
11
|
+
HTML
|
12
|
+
|
13
|
+
NO_TOC_HTML = <<-HTML
|
14
|
+
<h1>h1</h1>
|
15
|
+
<h1 class="no_toc">no_toc h1</h1>
|
16
|
+
<h2>h2</h2>
|
17
|
+
<h2 class="no_toc">no_toc h2</h2>
|
18
|
+
<h3>h3</h3>
|
19
|
+
<h3 class="no_toc">no_toc h3</h3>
|
20
|
+
<h4>h4</h4>
|
21
|
+
<h4 class="no_toc">no_toc h4</h4>
|
22
|
+
HTML
|
23
|
+
|
24
|
+
JAPANESE_HEADINGS_HTML = <<-HTML
|
25
|
+
<h1>あ</h1>
|
26
|
+
<h2>い</h2>
|
27
|
+
<h3>う</h3>
|
28
|
+
HTML
|
29
|
+
|
30
|
+
TAGS_INSIDE_HEADINGS_HTML = <<-HTML
|
31
|
+
<h2><strong>h2</strong></h2>
|
32
|
+
<h2><em>h2</em></h2>
|
33
|
+
HTML
|
34
|
+
|
6
35
|
TEST_HTML_1 = <<-HTML
|
7
36
|
<h1>h1</h1>
|
8
37
|
<h3>h3</h3>
|
@@ -33,23 +62,6 @@ class TestVariousTocHtml < Minitest::Test
|
|
33
62
|
<h5>h5</h5>
|
34
63
|
HTML
|
35
64
|
|
36
|
-
NO_TOC_HTML = <<-HTML
|
37
|
-
<h1>h1</h1>
|
38
|
-
<h1 class="no_toc">no_toc h1</h1>
|
39
|
-
<h2>h2</h2>
|
40
|
-
<h2 class="no_toc">no_toc h2</h2>
|
41
|
-
<h3>h3</h3>
|
42
|
-
<h3 class="no_toc">no_toc h3</h3>
|
43
|
-
<h4>h4</h4>
|
44
|
-
<h4 class="no_toc">no_toc h4</h4>
|
45
|
-
HTML
|
46
|
-
|
47
|
-
TEST_JAPANESE_HTML = <<-HTML
|
48
|
-
<h1>あ</h1>
|
49
|
-
<h2>い</h2>
|
50
|
-
<h3>う</h3>
|
51
|
-
HTML
|
52
|
-
|
53
65
|
def test_nested_toc
|
54
66
|
parser = Jekyll::TableOfContents::Parser.new(TEST_HTML_1)
|
55
67
|
doc = Nokogiri::HTML(parser.toc)
|
@@ -185,7 +197,7 @@ class TestVariousTocHtml < Minitest::Test
|
|
185
197
|
end
|
186
198
|
|
187
199
|
def test_japanese_toc
|
188
|
-
parser = Jekyll::TableOfContents::Parser.new(
|
200
|
+
parser = Jekyll::TableOfContents::Parser.new(JAPANESE_HEADINGS_HTML)
|
189
201
|
doc = Nokogiri::HTML(parser.toc)
|
190
202
|
expected = <<-HTML
|
191
203
|
<ul class="section-nav">
|
@@ -206,4 +218,33 @@ class TestVariousTocHtml < Minitest::Test
|
|
206
218
|
|
207
219
|
assert_equal(expected, actual)
|
208
220
|
end
|
221
|
+
|
222
|
+
def test_angle_bracket
|
223
|
+
parser = Jekyll::TableOfContents::Parser.new(ANGLE_BRACKET_HTML)
|
224
|
+
doc = Nokogiri::HTML(parser.toc)
|
225
|
+
expected = <<-HTML
|
226
|
+
<ul class="section-nav">
|
227
|
+
<li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
|
228
|
+
<li class="toc-entry toc-h1"><a href="#base-href"><base href></a></li>
|
229
|
+
<li class="toc-entry toc-h1"><a href="#--">& < ></a></li>
|
230
|
+
</ul>
|
231
|
+
HTML
|
232
|
+
actual = doc.css('ul.section-nav').to_s
|
233
|
+
|
234
|
+
assert_equal(expected, actual)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_tags_inside_heading
|
238
|
+
parser = Jekyll::TableOfContents::Parser.new(TAGS_INSIDE_HEADINGS_HTML)
|
239
|
+
doc = Nokogiri::HTML(parser.toc)
|
240
|
+
expected = <<-HTML
|
241
|
+
<ul class="section-nav">
|
242
|
+
<li class="toc-entry toc-h2"><a href="#h2">h2</a></li>
|
243
|
+
<li class="toc-entry toc-h2"><a href="#h2-1">h2</a></li>
|
244
|
+
</ul>
|
245
|
+
HTML
|
246
|
+
actual = doc.css('ul.section-nav').to_s
|
247
|
+
|
248
|
+
assert_equal(expected, actual)
|
249
|
+
end
|
209
250
|
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.7.
|
4
|
+
version: 0.7.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-09-
|
12
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|