html2doc 1.4.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/html2doc.gemspec +1 -1
- data/lib/html2doc/base.rb +1 -0
- data/lib/html2doc/lists.rb +25 -14
- data/lib/html2doc/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 834f2d69887ce656cd78e78822c78c98a19017e01ff1fbaffb5bcf9951fb1419
|
4
|
+
data.tar.gz: b7c12ae5d35ae84ac8de00d3cde42dc27549f5567623a5d88a50c3757a4c6dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a2b5f53337616b673d43f20a3f90594bcf5355288235d4eafe2622cac8e6af01d24ea2b05a8d2fea0fb9256b4d43686f3c81cb075ea562f6fcb616791abfeb
|
7
|
+
data.tar.gz: 565a6554f2de5e99bbaa9cc5de81e3c7d9789e36d9251641518cf82f44c2183a36a9305d2054535396813b21e475a31af1ca9577c9cb7c4bd7a9dbc0b872cf6b
|
data/html2doc.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
29
29
|
spec.add_dependency "image_size"
|
30
30
|
spec.add_dependency "mime-types"
|
31
|
-
spec.add_dependency "nokogiri", "~> 1.
|
31
|
+
spec.add_dependency "nokogiri", "~> 1.13"
|
32
32
|
spec.add_dependency "plane1converter", "~> 0.0.1"
|
33
33
|
spec.add_dependency "thread_safe"
|
34
34
|
spec.add_dependency "uuidtools"
|
data/lib/html2doc/base.rb
CHANGED
data/lib/html2doc/lists.rb
CHANGED
@@ -30,37 +30,48 @@ class Html2Doc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def list_add(xpath, liststyles, listtype, level)
|
33
|
-
xpath.
|
34
|
-
|
35
|
-
l["seen"] = true if level == 1
|
33
|
+
xpath.each do |l|
|
34
|
+
level == 1 and l["seen"] = true and @listnumber += 1
|
36
35
|
l["id"] ||= UUIDTools::UUID.random_create
|
37
36
|
(l.xpath(".//li") - l.xpath(".//ol//li | .//ul//li")).each do |li|
|
38
37
|
style_list(li, level, liststyles[listtype], @listnumber)
|
39
38
|
list_add1(li, liststyles, listtype, level)
|
40
39
|
end
|
41
|
-
l
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
list_add_tail(l, liststyles, listtype, level)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_add_tail(list, liststyles, listtype, level)
|
45
|
+
list.xpath(".//ul[not(ancestor::li/ancestor::*/@id = '#{list['id']}')] | "\
|
46
|
+
".//ol[not(ancestor::li/ancestor::*/@id = '#{list['id']}')]")
|
47
|
+
.each do |li|
|
48
|
+
list_add1(li.parent, liststyles, listtype, level - 1)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def list2para(list)
|
50
53
|
return if list.xpath("./li").empty?
|
51
54
|
|
52
|
-
list
|
53
|
-
list.xpath("./li").last["class"] ||= "MsoListParagraphCxSpLast"
|
54
|
-
list.xpath("./li/p").each { |p| p["class"] ||= "MsoListParagraphCxSpMiddle" }
|
55
|
+
list2para_position(list)
|
55
56
|
list.xpath("./li").each do |l|
|
56
57
|
l.name = "p"
|
57
58
|
l["class"] ||= "MsoListParagraphCxSpMiddle"
|
58
|
-
l
|
59
|
-
|
59
|
+
next unless l.first_element_child&.name == "p"
|
60
|
+
|
61
|
+
l["style"] += (l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "")
|
62
|
+
l.first_element_child.replace(l.first_element_child.children)
|
60
63
|
end
|
61
64
|
list.replace(list.children)
|
62
65
|
end
|
63
66
|
|
67
|
+
def list2para_position(list)
|
68
|
+
list.xpath("./li").first["class"] ||= "MsoListParagraphCxSpFirst"
|
69
|
+
list.xpath("./li").last["class"] ||= "MsoListParagraphCxSpLast"
|
70
|
+
list.xpath("./li/p").each do |p|
|
71
|
+
p["class"] ||= "MsoListParagraphCxSpMiddle"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
TOPLIST = "[not(ancestor::ul) and not(ancestor::ol)]".freeze
|
65
76
|
|
66
77
|
def lists1(docxml, liststyles, style)
|
@@ -72,7 +83,7 @@ class Html2Doc
|
|
72
83
|
else
|
73
84
|
list_add(docxml.xpath("//ol[@class = '#{style}']#{TOPLIST} | "\
|
74
85
|
"//ul[@class = '#{style}']#{TOPLIST}"),
|
75
|
-
|
86
|
+
liststyles, style, 1)
|
76
87
|
end
|
77
88
|
end
|
78
89
|
|
data/lib/html2doc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html2doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.13'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.13'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: plane1converter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -334,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
334
|
- !ruby/object:Gem::Version
|
335
335
|
version: '0'
|
336
336
|
requirements: []
|
337
|
-
rubygems_version: 3.3.
|
337
|
+
rubygems_version: 3.3.16
|
338
338
|
signing_key:
|
339
339
|
specification_version: 4
|
340
340
|
summary: Convert HTML document to Microsoft Word document
|