mato 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 0f46b573236cfe6df6101e6b1af416d30f49599f
4
- data.tar.gz: a33bef4d43f2681f75745be18dca5159bd631426
3
+ metadata.gz: 6e4685b308739fc1de3c616e18bd6e0b212da845
4
+ data.tar.gz: daea3d57330a9533caf058cf71e174132cef07fb
5
5
  SHA512:
6
- metadata.gz: 0de9be2d817df555c6158f3d7c97e9e829b6c00afa8b8245eefed902eff42b3bac6e5159dde4d33a9a18c2e217274bf7a621a65afe1f85027305302dcbd6d510
7
- data.tar.gz: cef99b815e789e7c71acf04c7a75a1669e1a04799b86cbbb9f6ea5a4757e11695ab6cc7545bed5e9dcbc2e3b5205664d86637f13841beffb38c8cf27af2aa260
6
+ metadata.gz: 04443f969138bd2a9943df1dad30e7d001fc4630efd75f68be484beb9fef8990c2fca6081e751d538841985df3f8275c8bc9a3c625b03f2bd45cfbf43d26b58b
7
+ data.tar.gz: c48fc06e567b09614cc184e672d1a2850b9159bbb75f1b7eab6db3bd65bdf274c4257b84c0beece0d90405d2a7ac242de6f01e2aa16004b19c8c5da04236c207
@@ -1,5 +1,11 @@
1
1
  # The revision history of Mato
2
2
 
3
+ ## v1.0.2 - 2017/08/23
4
+
5
+ https://github.com/bitjourney/mato/compare/v1.0.1...v1.0.2
6
+
7
+ * fix #3's issue again [#4](https://github.com/bitjourney/mato/pull/4)
8
+
3
9
  ## v1.0.1 - 2017/08/22
4
10
 
5
11
  https://github.com/bitjourney/mato/compare/v1.0.0...v1.0.1
@@ -7,6 +7,7 @@ module Mato
7
7
  class HtmlTocRenderer
8
8
 
9
9
  H_SELECTOR = %w(h1 h2 h3 h4 h5 h6).join(',')
10
+ ANCHOR_SELECTOR = "a.#{AnchorBuilder::CSS_CLASS_NAME}"
10
11
 
11
12
  # @param [Nokogiri::HTML::DocumentFragment] doc
12
13
  def call(doc)
@@ -24,26 +25,27 @@ module Mato
24
25
  s << %{</li></ul>\n}
25
26
  stack.pop
26
27
  end
28
+ else
29
+ s << %{</li>\n}
27
30
  end
28
31
 
29
- first_child = hx.child
30
- if anchor?(first_child)
31
- s << %{<li><a href="##{first_child['id']}">}
32
+ node = hx.dup
32
33
 
33
- child = first_child.next_sibling
34
- while child
35
- s << child.to_html
36
- child = child.next_sibling
37
- end
34
+ anchor = node.css(ANCHOR_SELECTOR).first
38
35
 
39
- s << %{</a>}
40
- else
41
- duped_hx = hx.dup
42
- duped_hx.css('a').each do |a|
43
- a.replace(a.children)
44
- end
36
+ s << %{<li>}
37
+ if anchor
38
+ s << %{<a href="##{anchor['id']}">}
39
+ anchor.unlink
40
+ end
45
41
 
46
- s << %{<li>#{duped_hx.children}}
42
+ node.css('a').each do |a|
43
+ a.replace(a.children)
44
+ end
45
+ s << node
46
+
47
+ if anchor
48
+ s << %{</a>}
47
49
  end
48
50
  end
49
51
 
@@ -61,11 +63,6 @@ module Mato
61
63
  def level(node)
62
64
  /\d+/.match(node.name)[0].to_i
63
65
  end
64
-
65
- # @param [Nokogiri::XML::Node] node
66
- def anchor?(node)
67
- node.name == 'a' && node['class'] == AnchorBuilder::CSS_CLASS_NAME
68
- end
69
66
  end
70
67
  end
71
68
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mato
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mato
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUJI Goro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri