jekyll-toc 0.7.0 → 0.7.1

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
2
  SHA256:
3
- metadata.gz: bf842397d274621c986cf5182baaed15cff4f406e309741621ca897545525cf0
4
- data.tar.gz: ac1181c4a77d63773b6fa12d3b646582b01e77aba41104291cf8c2bff3a6babb
3
+ metadata.gz: a98fa015f2cd16b45d6ea73f70f520f75270c27e4ca3a79258c817a475c573dc
4
+ data.tar.gz: a4274d04f1f0fe73d5e02e3f910d91012e21d0bd2911e6af8b78db1850888dfa
5
5
  SHA512:
6
- metadata.gz: f01826275203ce38ebdc8d8ce427e91bf9f8e1c4e437803caf5a3073fe44e5cdc4b022f4319199ec3eeca2b834cf8a282bfd38843bfb5d7bd918958c90994722
7
- data.tar.gz: 0df513610cb1aa29706f069404424d66d0e50252b3df93254c8419cf7a297497b96eb9ba33506b53f3f56681950f4f14881fb3156e2f50713d708ee4fe4d8e9e
6
+ metadata.gz: 5c4c08e4c22c891df141d3a12c9a2c46127b07b3afadd5a68cdf81d1f59fd9f17b35c8f8013e461f4a466c1a561539f010ec8433104867c2a6d90397ecd61fbd
7
+ data.tar.gz: b20a95d26d6435f55d874f740f8c4560cc139ae3b44073fe46911f5289fe7cb9b874642554318b7ad7ad6ba4bcd2471e49d3ef97473d554fba32ce22c1d5f99e
@@ -57,7 +57,7 @@ module Jekyll
57
57
  entries << {
58
58
  id: id,
59
59
  uniq: uniq,
60
- text: text,
60
+ text: CGI.escapeHTML(text),
61
61
  node_name: node.name,
62
62
  content_node: header_content,
63
63
  h_num: node.name.delete('h').to_i
@@ -1,3 +1,3 @@
1
1
  module JekyllToc
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.7.1'.freeze
3
3
  end
@@ -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>&lt;base href&gt;</h1>
10
+ <h1>&amp; &lt; &gt;</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(TEST_JAPANESE_HTML)
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">&lt;base href&gt;</a></li>
229
+ <li class="toc-entry toc-h1"><a href="#--">&amp; &lt; &gt;</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.0
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-29 00:00:00.000000000 Z
12
+ date: 2018-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri