html2doc 1.4.1 → 1.4.2

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: 6308b5b6d0b45a9bef654d55c71bac49ee06b30b44ff357c9eef75b94581faa9
4
- data.tar.gz: 333711eb9d5830a57c980284d0bce80b3af1428944092e7809943d41e78a0d1c
3
+ metadata.gz: 834f2d69887ce656cd78e78822c78c98a19017e01ff1fbaffb5bcf9951fb1419
4
+ data.tar.gz: b7c12ae5d35ae84ac8de00d3cde42dc27549f5567623a5d88a50c3757a4c6dcd
5
5
  SHA512:
6
- metadata.gz: bbd32c72039861123ed3957b1b26d204759cb4bfd6e05a35c1b6be9ca10d23b12e63df1ed0ba8581afa1687196fc9ade2e9939cd8bec287eda7cf61a2a9df285
7
- data.tar.gz: '087c984c4f8a6e530db669ba1a8725418c4124a1e713f29a40e66237be12af5faa19d2eaea52fbcfd930362e39d436528d0df4adbf9abf8b5d1b8b5db059fc91'
6
+ metadata.gz: 02a2b5f53337616b673d43f20a3f90594bcf5355288235d4eafe2622cac8e6af01d24ea2b05a8d2fea0fb9256b4d43686f3c81cb075ea562f6fcb616791abfeb
7
+ data.tar.gz: 565a6554f2de5e99bbaa9cc5de81e3c7d9789e36d9251641518cf82f44c2183a36a9305d2054535396813b21e475a31af1ca9577c9cb7c4bd7a9dbc0b872cf6b
@@ -30,37 +30,48 @@ 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"] += (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
- liststyles, style, 1)
86
+ liststyles, style, 1)
76
87
  end
77
88
  end
78
89
 
@@ -1,3 +1,3 @@
1
1
  class Html2Doc
2
- VERSION = "1.4.1".freeze
2
+ VERSION = "1.4.2".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.1
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-05-16 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
@@ -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