html2doc 0.6.5 → 0.6.6

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
  SHA1:
3
- metadata.gz: a81b1c785ccf5bf053bcfc9bc447c56c950aa5d0
4
- data.tar.gz: f6eecc7cb0d39c318d75d8b8ce15bd472fcbe730
3
+ metadata.gz: 12bd3e1d492aa03c842f52352b18c0145650bb84
4
+ data.tar.gz: c45c11401392dcdc05f03d4ca4c1ff71326e329c
5
5
  SHA512:
6
- metadata.gz: 7b851e4484c4c76cd2401b1421599f4d9ceb6feece0298e9c2ddf75975fcc373174c4b1073e7efdeb94f60990dc8f73fe1a641c188f98550c0f0c789a0dbb879
7
- data.tar.gz: 03bfaccc89670d711ee63dfafb8a7acae8815a18efb827ae512f0028d2ab9d58f878744ff4fe8135c385e3626e373cb0ada8fc34ac5ec3b8c73d26af94cfc19a
6
+ metadata.gz: 522afed658b3d1cc6c853f6efad77874400778bce23b68f186721bc7660bab3041ceaa96291ef3af7d4c49bf297c4a26b5080fcd80e1d58e2f513e42ffb13fd0
7
+ data.tar.gz: 12e5759f2558959ca6abd89f8c7329bcba74151b7849dc698cc0af8094d2d76e38c60d1f557f0b1dae60d8bf159b53eabfbf0c9f5630f796524e3c9d57c08b9f
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.8.1"
31
+ spec.add_dependency "nokogiri"
32
32
  spec.add_dependency "thread_safe"
33
33
  spec.add_dependency "uuidtools"
34
34
  spec.add_dependency "ruby-xslt"
@@ -6,23 +6,23 @@ require "xml/xslt"
6
6
  require "pp"
7
7
 
8
8
  module Html2Doc
9
- def self.style_list(li, level, listno)
10
- return unless listno
9
+ def self.style_list(li, level, liststyle, listnumber)
10
+ return unless liststyle
11
11
  if li["style"]
12
12
  li["style"] += ";"
13
13
  else
14
14
  li["style"] = ""
15
15
  end
16
- # I don't know what the lfo-n attribute is. I doubt Micro$oft now does either.
17
- li["style"] += "mso-list:#{listno} level#{level} lfo1;"
16
+ li["style"] += "mso-list:#{liststyle} level#{level} lfo#{listnumber};"
18
17
  end
19
18
 
20
- def self.list_add(xpath, liststyles, listtype, level)
21
- xpath.each do |list|
19
+ def self.list_add(xpath, liststyles, listtype, level, listnumber)
20
+ xpath.each_with_index do |list, i|
21
+ listnumber = i + 1 if level == 1
22
22
  (list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |li|
23
- style_list(li, level, liststyles[listtype])
24
- list_add(li.xpath(".//ul") - li.xpath(".//ul//ul | .//ol//ul"), liststyles, :ul, level + 1)
25
- list_add(li.xpath(".//ol") - li.xpath(".//ul//ol | .//ol//ol"), liststyles, :ol, level + 1)
23
+ style_list(li, level, liststyles[listtype], listnumber)
24
+ list_add(li.xpath(".//ul") - li.xpath(".//ul//ul | .//ol//ul"), liststyles, :ul, level + 1, listnumber)
25
+ list_add(li.xpath(".//ol") - li.xpath(".//ul//ol | .//ol//ol"), liststyles, :ol, level + 1, listnumber)
26
26
  end
27
27
  end
28
28
  end
@@ -30,10 +30,10 @@ module Html2Doc
30
30
  def self.lists(docxml, liststyles)
31
31
  return if liststyles.nil?
32
32
  if liststyles.has_key?(:ul)
33
- list_add(docxml.xpath("//ul[not(ancestor::ul) and not(ancestor::ol)]"), liststyles, :ul, 1)
33
+ list_add(docxml.xpath("//ul[not(ancestor::ul) and not(ancestor::ol)]"), liststyles, :ul, 1, nil)
34
34
  end
35
35
  if liststyles.has_key?(:ol)
36
- list_add(docxml.xpath("//ol[not(ancestor::ul) and not(ancestor::ol)]"), liststyles, :ol, 1)
36
+ list_add(docxml.xpath("//ol[not(ancestor::ul) and not(ancestor::ol)]"), liststyles, :ol, 1, nil)
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "0.6.5".freeze
2
+ VERSION = "0.6.6".freeze
3
3
  end
@@ -551,4 +551,24 @@ RSpec.describe Html2Doc do
551
551
  OUTPUT
552
552
  end
553
553
 
554
+
555
+ it "restarts numbering of lists with list styles" do
556
+ simple_body = <<~BODY
557
+ <div>
558
+ <ol><li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol>
559
+ <ol><li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol></div>
560
+ BODY
561
+ Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
562
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
563
+ to match_fuzzy(<<~OUTPUT)
564
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
565
+ #{word_body('<div>
566
+ <ol><li style="mso-list:l2 level1 lfo1;" class="MsoNormal"><div><p class="MsoNormal"><ol><li style="mso-list:l2 level2 lfo1;" class="MsoNormal"><ul><li style="mso-list:l1 level3 lfo1;" class="MsoNormal"><p class="MsoNormal"><ol><li style="mso-list:l2 level4 lfo1;" class="MsoNormal"><ol><li style="mso-list:l2 level5 lfo1;" class="MsoNormal">A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol>
567
+ <ol><li style="mso-list:l2 level1 lfo2;" class="MsoNormal"><div><p class="MsoNormal"><ol><li style="mso-list:l2 level2 lfo2;" class="MsoNormal"><ul><li style="mso-list:l1 level3 lfo2;" class="MsoNormal"><p class="MsoNormal"><ol><li style="mso-list:l2 level4 lfo2;" class="MsoNormal"><ol><li style="mso-list:l2 level5 lfo2;" class="MsoNormal">A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol></div>',
568
+ '<div style="mso-element:footnote-list"/>')}
569
+ #{WORD_FTR1}
570
+ OUTPUT
571
+ end
572
+
573
+
554
574
  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: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.8.1
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.1
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thread_safe
71
71
  requirement: !ruby/object:Gem::Requirement