html2doc 1.4.0.1 → 1.4.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39f218409dbbaa66345a38c3ac768bde9def9ffffa4fb40b388366994c28cba3
4
- data.tar.gz: c3eb9ec0b62796ca8cd165c787f03a752e3ba92ff01f4fcedac7c47099e3b6f9
3
+ metadata.gz: 8c9737d99ed7f4eaa814bd07e97e5b11b54f1f27a07c628b97e21216b9a3a816
4
+ data.tar.gz: 7778c03a49a8223a873f139fda9722a451700d6c39df1003dde40bf8cb8e6bfb
5
5
  SHA512:
6
- metadata.gz: 5de663e28833714b38e902ecb78f567f1e6734ab7998c12f37aec432a44694b8f5e8f868b861a443716b1a88d05c60e92fc298b2f9d608e6370c74d0ad0170f6
7
- data.tar.gz: 5e508c5589940b6b50cb16de23d8de07717d82807308e4980ae8206a219778a0ef3ae835afd87d021f835ffd218675e557cea0fb396fc85707e6df9502cab118
6
+ metadata.gz: b9b0479132c6115e69449fec5797c3e30007790940c9530f59cb74c5bf8598f1d01b6c180c42a9bc87880c86636cf9719f4e704036f2afe8adb264312867d1eb
7
+ data.tar.gz: 616429b25b5cd9d59db066f5085fb19a5d79d308d38cb0f4360ec66e85a3dc1163d5707de433155226e72cb86b065dbe03e9e07c9f1eb6dae66300a0169846e5
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.12"
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"
@@ -30,37 +30,49 @@ class Html2Doc
30
30
  end
31
31
 
32
32
  def list_add(xpath, liststyles, listtype, level)
33
- xpath.each_with_index do |l, _i|
34
- @listnumber += 1 if level == 1
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.xpath(".//ul[not(ancestor::li/ancestor::*/@id = '#{l['id']}')] | "\
42
- ".//ol[not(ancestor::li/ancestor::*/@id = '#{l['id']}')]")
43
- .each do |li|
44
- list_add1(li.parent, liststyles, listtype, level - 1)
45
- end
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.xpath("./li").first["class"] ||= "MsoListParagraphCxSpFirst"
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&.first_element_child&.name == "p" and
59
- l.first_element_child.replace(l.first_element_child.children)
59
+ next unless l.first_element_child&.name == "p"
60
+
61
+ l["style"] ||= ""
62
+ l["style"] += (l.first_element_child["style"]&.sub(/mso-list[^;]+;/, "") || "")
63
+ l.first_element_child.replace(l.first_element_child.children)
60
64
  end
61
65
  list.replace(list.children)
62
66
  end
63
67
 
68
+ def list2para_position(list)
69
+ list.xpath("./li").first["class"] ||= "MsoListParagraphCxSpFirst"
70
+ list.xpath("./li").last["class"] ||= "MsoListParagraphCxSpLast"
71
+ list.xpath("./li/p").each do |p|
72
+ p["class"] ||= "MsoListParagraphCxSpMiddle"
73
+ end
74
+ end
75
+
64
76
  TOPLIST = "[not(ancestor::ul) and not(ancestor::ol)]".freeze
65
77
 
66
78
  def lists1(docxml, liststyles, style)
@@ -72,7 +84,7 @@ class Html2Doc
72
84
  else
73
85
  list_add(docxml.xpath("//ol[@class = '#{style}']#{TOPLIST} | "\
74
86
  "//ul[@class = '#{style}']#{TOPLIST}"),
75
- liststyles, style, 1)
87
+ liststyles, style, 1)
76
88
  end
77
89
  end
78
90
 
@@ -1,3 +1,3 @@
1
1
  class Html2Doc
2
- VERSION = "1.4.0.1".freeze
2
+ VERSION = "1.4.2.1".freeze
3
3
  end
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.0.1
4
+ version: 1.4.2.1
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-05-03 00:00:00.000000000 Z
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.12'
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.12'
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.9
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