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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0e364a04d1f6b28e869fa10acc2c8ed5e586e02855c6549258a3d413e4d7a8b
4
- data.tar.gz: 9a960fad67899850bd7ad186c315d378f8d4b2c8ef27cd10bc66649f48fecfcc
3
+ metadata.gz: dbafa01a04b39fc1b1c7932284f63cc1443d27b6b81cacb20c747a442c3deac6
4
+ data.tar.gz: effb258366add55af68d8986419f0e7e927fc2c7ab3e562ebd1b74788aa94177
5
5
  SHA512:
6
- metadata.gz: 34e5350a846ee510f7f889b385e3d96d48b8f6eca87c642b551edb6b1a0cf02be8e75ae46db4cd53e74bdda6d96fbcc93774549c2194e996d3b0a722d3988e9f
7
- data.tar.gz: 935916fca4151dbb0049bd069ffc45cc821c01b61c83dc36c336ead07b3b02d1c46b329e860a1f429817e91578834b10690d037cd4acea5a9f13f42c8984824a
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentfulConverter
4
- VERSION = '0.0.1.16'
4
+ VERSION = '0.0.1.17'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.16
4
+ version: 0.0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Avlonitis