openstax_content 0.2.0 → 0.2.1

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: b17dd5822cd85c27b9d83850a0324d3633ef05bfd11793b9ac05bb734a0b8de3
4
- data.tar.gz: 36be3946382c3f472ca4cc200ad2e7899505d4abc4101f0d94caebe287fc8d19
3
+ metadata.gz: 760f80ecbe0193cdb9597862fd3d62e2bd687affa9c392ca07cd41440f5e7a62
4
+ data.tar.gz: f357ee9efc8c537f6c84c8e02fc15e0919691be79be677e413ba7542220a1ab0
5
5
  SHA512:
6
- metadata.gz: d32296abfb1ff02ea5781b62caf6616516459bb66f7a6615fdee3dc66481749f09c42e89df7ff28846b0a5fb97677b8d683150c0e60fa3c8eb4f0c7e870659b9
7
- data.tar.gz: fab8643c3358e3cf02be92f59da7a3fc73338dbf679b1e38eeb4fc1364dc8d117c87913de960643e74c649806509694ebf56e68c38c1863e523191fa3d31f8e5
6
+ metadata.gz: 78bf8346586fea75e4cc1d5eed2f5e083a6feb75974f71838b83c90383f9df1f6742a47203a60d9e3e293b855b5bf30bbe7eb78e5536f1f6b4847757fc24b3a0
7
+ data.tar.gz: 162cf2c108e2c94e1c11dea32baf337c82ec0965783aa6358209b58888cc389ecc7953e637c802511ce167603f1b9081fb346e3e32b787304f9a4c6740fbe75b
@@ -17,12 +17,21 @@ class OpenStax::Content::Fragment::Html < OpenStax::Content::Fragment
17
17
  super.except('node')
18
18
  end
19
19
 
20
- def html?
21
- !to_html.empty?
20
+ def blank?
21
+ return @blank unless @blank.nil?
22
+
23
+ @blank = if to_html.nil? || to_html.strip.empty?
24
+ true
25
+ else
26
+ node_without_title = node.dup
27
+ node_without_title.css('[data-type="document-title"]').remove
28
+ text = node_without_title.text
29
+ text.nil? || text.strip.empty?
30
+ end
22
31
  end
23
32
 
24
- def blank?
25
- !html?
33
+ def html?
34
+ !blank?
26
35
  end
27
36
 
28
37
  def node
@@ -40,9 +40,11 @@ class OpenStax::Content::FragmentSplitter
40
40
  # Flatten, remove empty nodes and transform remaining nodes into reading fragments
41
41
  result.map do |obj|
42
42
  next obj unless obj.is_a?(Nokogiri::XML::Node)
43
- next if obj.content.nil? || obj.content.strip.empty?
44
43
 
45
- OpenStax::Content::Fragment::Reading.new node: obj, reference_view_url: reference_view_url
44
+ fragment = OpenStax::Content::Fragment::Reading.new(
45
+ node: obj, reference_view_url: reference_view_url
46
+ )
47
+ fragment unless fragment.blank?
46
48
  end.compact.tap do |result|
47
49
  @media_nodes.each do |node|
48
50
  # Media processing instructions
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Content
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3