readability_js 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ce8fc0727f6b8ce1bfc45cf586b58c0e895deb95ba8f5f341a0d41ed6e9a9ba
4
- data.tar.gz: 5baf642f9053d3c0adb9b81e04f9ff0d4b0252725274827143340fcb6f4067cf
3
+ metadata.gz: e656198387a824f6e6bdb7a3e4ccf3f5173100782c94dc9a0462dd8dc6423ef4
4
+ data.tar.gz: b31a6cf4c54563a55844c4fa852ca27804f8ae9d9acb31dfdbcc66d5d58be14c
5
5
  SHA512:
6
- metadata.gz: 3ee241f68497574ea9477afa66e1b605007446f36ea29fcd4760581891e7482b167249e2dd502254e4407bee1cb22501eea40b74be920a4097de656f808690ac
7
- data.tar.gz: 8d8d6a3d85108e590762ed17f70f12142d8aca5787abaf8cb3fc5160b47aa5e7397605bf1bcbedb17fd3761335862223c45426e3be13d3bdfe1c288084396690
6
+ metadata.gz: faedb480cfb28b6b73c6d6b6779979758427ba202177abe1cd0947073fb94296521ad42b58c9dab867d0b546187a9844892b7b6a4d0d2d2960a7f77b9c96b6e5
7
+ data.tar.gz: b227cfc77004de40ea9e12fa16a3838cb59871687c7986e7efdd4f28c0a7f078a7ab07184b0ead21511f237857a7a2ec41042f85a5b20f2abf19acfb1e6d69f5
@@ -148,7 +148,7 @@ module ReadabilityJs
148
148
  # @return [String] The cleaned HTML content as a string.
149
149
  #
150
150
  def self.clean_up_comments(html)
151
- copy = html.dup
151
+ copy = html.dup || ""
152
152
  # Turn \x3C before comment start into '<'
153
153
  copy.gsub!(/\\x3C(?=!--)/, '<')
154
154
  # Decode encoded comment end --&gt; to -->
@@ -204,9 +204,9 @@ module ReadabilityJs
204
204
  end
205
205
  # Check for image and if none is found, add after title if available
206
206
  if result.key?("image_url") && !result["image_url"].to_s.strip.empty?
207
- has_image = mark_down.match(/!\[.*?\]\(.*?\)/)
207
+ has_image = mark_down.match(/!\[.*?\]\(.*?\)/) || mark_down.match(/<img\b[^>]*>/) || mark_down.match(/<picture\b[^>]*>.*?<\/picture>/m)
208
208
  if !has_image
209
- img_md = "![Lead Image](#{result['image_url']})\n\n"
209
+ img_md = "![image](#{result['image_url']})\n\n"
210
210
  mark_down = mark_down.sub(/^# .+?\n/, "\\0" + img_md)
211
211
  end
212
212
  end
@@ -237,7 +237,7 @@ module ReadabilityJs
237
237
  # check for img tags but also for picture tags
238
238
  has_image = !doc.css('img, picture').empty?
239
239
  if !has_image
240
- img_tag = "<p><img src=\"#{result['image_url']}\" alt=\"Lead Image\"></p>\n"
240
+ img_tag = "<p><img src=\"#{result['image_url']}\"></p>\n"
241
241
  h1 = doc.at_css('h1')
242
242
  if h1
243
243
  h1.add_next_sibling(Nokogiri::HTML::DocumentFragment.parse(img_tag))
@@ -1,3 +1,3 @@
1
1
  module ReadabilityJs
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readability_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthäus Beyrle