yatoc 0.2.0 → 0.2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/yatoc.rb +12 -7
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2166264952987dfcd34e23217e9d9184438822109366478cd888be296ac63d3
|
4
|
+
data.tar.gz: 6adcef0d31574c4e833c9bc5780ae3ca15e45dbf88e73385632e838d5efbdd33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0a83971d92e394880af82b6d32f87ad05b5becaa44e52b73febd1dce22d6c47758b03978fd55af5b96098a0d4c0a082a643c37ed979a9b3d625e7ee9648bb9
|
7
|
+
data.tar.gz: f85eb87148e2407f7db9b7a7711c5f8c327c0ed849543a715490d7b1db80c698cad5cb5d9b156721cad10fbf06c56fea2fb3d60ea416383bb270c35c6a9bc048
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/yatoc.rb
CHANGED
@@ -12,9 +12,9 @@ class Yatoc
|
|
12
12
|
|
13
13
|
attr_reader :to_html, :to_toc
|
14
14
|
|
15
|
-
def initialize(html, min_sections: 3, debug: false)
|
15
|
+
def initialize(html, min_sections: 3, numbered: true, debug: false)
|
16
16
|
|
17
|
-
@debug = debug
|
17
|
+
@numbered, @debug = numbered, debug
|
18
18
|
|
19
19
|
@to_html = html.scan(/<h\d+/).length > min_sections ? gen_toc(html) : html
|
20
20
|
|
@@ -29,7 +29,7 @@ class Yatoc
|
|
29
29
|
|
30
30
|
a2 = make_tree(a)
|
31
31
|
puts a2.inspect.debug if @debug
|
32
|
-
raw_html = LineTree.new(a2).to_html(numbered:
|
32
|
+
raw_html = LineTree.new(a2).to_html(numbered: @numbered)
|
33
33
|
|
34
34
|
puts ('raw_html: ' + raw_html.inspect).debug if @debug
|
35
35
|
toc = make_linkable(raw_html)
|
@@ -49,14 +49,19 @@ class Yatoc
|
|
49
49
|
|
50
50
|
link = node.text ? '#' + node.text.strip.downcase.gsub(' ', '-') : ''
|
51
51
|
anchor = Rexle::Element.new('a', attributes: {href: link})
|
52
|
-
anchor.add Rexle::Element.new('span', value: node\
|
53
|
-
.attributes[:id][1..-1].gsub('-','.'))
|
54
52
|
|
55
|
-
|
53
|
+
if @numbered then
|
54
|
+
anchor.add Rexle::Element.new('span', value: node\
|
55
|
+
.attributes[:id][1..-1].gsub('-','.'))
|
56
|
+
node.attributes.delete :id
|
57
|
+
anchor.children << ' ' + node.text if node.text
|
58
|
+
else
|
59
|
+
anchor.text = node.text if node.text
|
60
|
+
end
|
61
|
+
|
56
62
|
|
57
63
|
node.add anchor
|
58
64
|
node.text = ''
|
59
|
-
node.attributes.delete :id
|
60
65
|
|
61
66
|
end
|
62
67
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yatoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
7RVV+J+oYjvww0tYfGq6N2tECM5thrQYj3cKLzAEEPYBjoWcPA5bqRXBTNta+k+K
|
36
36
|
tc7DELyeAZoKgZBO2wAc4FQ6
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-12-
|
38
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
metadata.gz.sig
CHANGED
Binary file
|