yatoc 0.2.2 → 0.2.3
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 +29 -8
- data.tar.gz.sig +0 -0
- metadata +22 -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: 12de299cd3e07213f177e2f3f5b16df8fb47e01ad0082aee2f54dc5c7346371d
|
4
|
+
data.tar.gz: 128d559f367e127ca25eaa09bfd6d41770f9cf224f426ceceed263a61b38a525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0574299ff5a353b4376b3590320facf152a77296cd324d1d5830241ef865f9d550b911e70e56d932e733bd3d6623526d08206b4025abd158798b03d2530cc3d
|
7
|
+
data.tar.gz: b6f99d5cdac709c5b32df535c529c78026d7e2db8b05ce7ba0723a2b92c69ba6acd564479e44a1981d3aa9c30ce4b16f816f647b926c221d9c710b9dd209ca69
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/yatoc.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
# description: Yet Another Table Of Contents HTML generator
|
6
6
|
|
7
|
+
require 'pxindex'
|
7
8
|
require 'line-tree'
|
8
9
|
|
9
10
|
|
@@ -14,19 +15,21 @@ class Yatoc
|
|
14
15
|
|
15
16
|
def initialize(html, min_sections: 3, numbered: true, debug: false)
|
16
17
|
|
17
|
-
@numbered, @debug = numbered, debug
|
18
|
+
@numbered, @debug, @html = numbered, debug, html
|
18
19
|
|
19
|
-
if html.scan(/<h\d+/).length > min_sections then
|
20
|
-
|
21
|
-
gen_index(html)
|
22
|
-
@to_html = gen_toc(html)
|
20
|
+
@to_html = if html.scan(/<h\d+/).length > min_sections then
|
23
21
|
|
22
|
+
gen_toc(html)
|
24
23
|
|
25
24
|
else
|
26
25
|
html
|
27
26
|
end
|
28
27
|
|
29
28
|
end
|
29
|
+
|
30
|
+
def to_index(threshold: 5)
|
31
|
+
gen_index(@html, threshold: threshold)
|
32
|
+
end
|
30
33
|
|
31
34
|
private
|
32
35
|
|
@@ -44,13 +47,31 @@ class Yatoc
|
|
44
47
|
|
45
48
|
end
|
46
49
|
|
47
|
-
def gen_index(html)
|
50
|
+
def gen_index(html, threshold: 5)
|
48
51
|
|
49
52
|
a = html.split(/(?=<h2)/)
|
53
|
+
puts ('gen_index a: ' + a.inspect).debug if @debug
|
50
54
|
|
51
|
-
|
55
|
+
if a.length < threshold then
|
56
|
+
|
57
|
+
index = build_html(a)
|
52
58
|
|
53
|
-
|
59
|
+
@to_index = "<div id='index' class='index'>\n%s\n</div>\n\n" % index
|
60
|
+
|
61
|
+
else
|
62
|
+
|
63
|
+
a = scan_headings html
|
64
|
+
puts ('_a: ' + a.inspect).debug if @debug
|
65
|
+
|
66
|
+
s = make_tree(a)
|
67
|
+
puts ('s: ' + s.inspect).debug if @debug
|
68
|
+
|
69
|
+
px = PxIndex.new
|
70
|
+
px.import(s)
|
71
|
+
|
72
|
+
@to_index = "<div id='azindex' class='azindex'>\n%s\n</div>\n\n" \
|
73
|
+
% px.build_html
|
74
|
+
end
|
54
75
|
|
55
76
|
end
|
56
77
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,8 +35,28 @@ cert_chain:
|
|
35
35
|
7RVV+J+oYjvww0tYfGq6N2tECM5thrQYj3cKLzAEEPYBjoWcPA5bqRXBTNta+k+K
|
36
36
|
tc7DELyeAZoKgZBO2wAc4FQ6
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-01-
|
38
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: pxindex
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.2'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.2.2
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.2'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.2.2
|
40
60
|
- !ruby/object:Gem::Dependency
|
41
61
|
name: line-tree
|
42
62
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|