doctor_ninja 0.2.1 → 0.2.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
  SHA1:
3
- metadata.gz: 2921481a3396a0717131168ad086b2a488085758
4
- data.tar.gz: 4d3d327ffe2fd66ec8bd6623061653cf56b67535
3
+ metadata.gz: f3efb5d812b73e86bdffa9691b2fc5771b3e63a9
4
+ data.tar.gz: 7634228321fd0a2a191952ddf81cb0b357b7b59e
5
5
  SHA512:
6
- metadata.gz: ee7148bb8d153b386df243a276126069b0197975c2c3a91cb5821dd423993fc948cb4d544f62f0662de8a22297805521d81d8e45967e275fd3cd87d3999a01ee
7
- data.tar.gz: a67c98ce38d274e637764e96f67431d02a7f0485ea5d73ad6711704ac635c4b0fd4ff46c6caf9294c9de48376daaf958a9ee1804198866b9474352e342926573
6
+ metadata.gz: f50b1af5c84af5c559bc35122b621a34f3917c020ca84d3a4b01301cccdb1a5ac6108a0cd26bd0bbbf186b7498a8e8cfecda23c98b055517ba1c2bbce4feab98
7
+ data.tar.gz: c1279f1ac07c93bb93551cd89a3aafa92f835a947a37f6b619f82f13e6409f1f22f527ebbb6cb73b11a5c6f7a413a7ce94ed075ce0b251aa6d643e5b0aa229b8
@@ -31,7 +31,7 @@ class DoctorNinja::Parsers::List < DoctorNinja::Parsers::Base
31
31
 
32
32
  prefix = ""
33
33
  # Add <ul> if is start of new list
34
- if previous.length == 0 || get_pr("w:ilvl", previous) < lvl
34
+ if previous.length == 0 || get_pr("w:ilvl", previous).to_i < lvl.to_i
35
35
  prefix += "<#{tag}#{typeAttr}>"
36
36
  end
37
37
 
@@ -39,16 +39,22 @@ class DoctorNinja::Parsers::List < DoctorNinja::Parsers::Base
39
39
 
40
40
  suffix = ""
41
41
 
42
- if following.length == 0
43
- suffix += "</li></#{tag}>"
44
- else
45
- f_lvl = get_pr("w:ilvl", following)
46
- if f_lvl < lvl
47
- suffix += "</li></#{tag}></li>"
48
- elsif f_lvl == lvl
49
- suffix += "</li>"
42
+ f_lvl = (following.length == 0) ? -1 : get_pr("w:ilvl", following)
43
+
44
+ closings = (f_lvl.to_i..lvl.to_i).map do |l|
45
+ if l == lvl.to_i
46
+ # Close only this item
47
+ "</li>"
48
+ elsif l < lvl.to_i && l >= 0
49
+ # Close list level
50
+ "</#{tag}></li>"
51
+ else
52
+ # Close entire list
53
+ "</#{tag}>"
50
54
  end
51
- end
55
+ end.reverse
56
+
57
+ suffix = closings.join("")
52
58
 
53
59
  "#{prefix}#{parse_children}#{suffix}"
54
60
  end
@@ -1,3 +1,3 @@
1
1
  module DoctorNinja
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -43,4 +43,11 @@ class ListsTest < MiniTest::Test
43
43
  assert_includes result, "<ol type='a'><li>Lower Alpha</li></ol>"
44
44
  assert_includes result, "<ol type='A'><li>Upper Alpha</li></ol>"
45
45
  end
46
+
47
+ def test_list_ending_in_indented_level
48
+ result = parse_file "test/fixtures/list_ending_in_indented_level.docx"
49
+ result = strip_spaces(result)
50
+ assert_includes result, "<ul><li>First<ul><li>Second</li></ul></li></ul>"
51
+ refute_includes result, "</ul></li></ul></li>"
52
+ end
46
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctor_ninja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Amorim
@@ -180,6 +180,7 @@ files:
180
180
  - test/fixtures/img_rot_crop.docx
181
181
  - test/fixtures/invalid_file.docx
182
182
  - test/fixtures/limites.docx
183
+ - test/fixtures/list_ending_in_indented_level.docx
183
184
  - test/fixtures/ordered_list.docx
184
185
  - test/fixtures/ordered_list_types.docx
185
186
  - test/fixtures/unordered_list.docx
@@ -222,6 +223,7 @@ test_files:
222
223
  - test/fixtures/img_rot_crop.docx
223
224
  - test/fixtures/invalid_file.docx
224
225
  - test/fixtures/limites.docx
226
+ - test/fixtures/list_ending_in_indented_level.docx
225
227
  - test/fixtures/ordered_list.docx
226
228
  - test/fixtures/ordered_list_types.docx
227
229
  - test/fixtures/unordered_list.docx