doctor_ninja 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/doctor_ninja/parsers/list.rb +16 -10
- data/lib/doctor_ninja/version.rb +1 -1
- data/test/fixtures/list_ending_in_indented_level.docx +0 -0
- data/test/lists_test.rb +7 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3efb5d812b73e86bdffa9691b2fc5771b3e63a9
|
4
|
+
data.tar.gz: 7634228321fd0a2a191952ddf81cb0b357b7b59e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
elsif
|
49
|
-
|
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
|
data/lib/doctor_ninja/version.rb
CHANGED
Binary file
|
data/test/lists_test.rb
CHANGED
@@ -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.
|
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
|