contentful_converter 0.0.1.16 → 0.0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contentful_converter/nokogiri_builder.rb +10 -2
- data/lib/contentful_converter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbafa01a04b39fc1b1c7932284f63cc1443d27b6b81cacb20c747a442c3deac6
|
4
|
+
data.tar.gz: effb258366add55af68d8986419f0e7e927fc2c7ab3e562ebd1b74788aa94177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fc62e6020fec4de25fdf121d453dbc1a67df39c57054bec14c89a8161f608649c715a96731237112bca956814315be7fa2cb461e6ca4ecf63825b1213634968
|
7
|
+
data.tar.gz: dc60ca6d301860eb1132be2605ec2a37ae28e0c6e19f9bd54f2153b371890fe1375d2188f3b0cb9362beb23f24a80c9e96c8c52b839f18c417ac39041bba3765
|
@@ -19,13 +19,13 @@ module ContentfulConverter
|
|
19
19
|
|
20
20
|
def sanitize(html)
|
21
21
|
doc = create_nokogiri_fragment(html)
|
22
|
-
doc.css('section').each { |elem| elem.name = 'p' }
|
23
|
-
doc.css('div').each { |elem| elem.name = 'p' }
|
22
|
+
doc.css('section', 'div').each { |elem| elem.name = 'p' }
|
24
23
|
doc.to_html
|
25
24
|
end
|
26
25
|
|
27
26
|
def normalize_lists(nokogiri_fragment)
|
28
27
|
find_li(nokogiri_fragment).each { |li_node| wrap_parents_in_ul(li_node) }
|
28
|
+
find_list_groups(nokogiri_fragment).each { |elem| clear_children(elem) }
|
29
29
|
|
30
30
|
nokogiri_fragment
|
31
31
|
end
|
@@ -34,6 +34,14 @@ module ContentfulConverter
|
|
34
34
|
nokogiri_fragment.css('li')
|
35
35
|
end
|
36
36
|
|
37
|
+
def find_list_groups(nokogiri_fragment)
|
38
|
+
nokogiri_fragment.css('ol', 'ul')
|
39
|
+
end
|
40
|
+
|
41
|
+
def clear_children(elem)
|
42
|
+
elem.children.each { |child| child.remove unless child.name == 'li' }
|
43
|
+
end
|
44
|
+
|
37
45
|
def wrap_parents_in_ul(node)
|
38
46
|
return if node.parent.name == 'ul' || node.parent.name == 'ol'
|
39
47
|
|