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 +4 -4
- data/lib/readability_js/extended.rb +4 -4
- data/lib/readability_js/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: e656198387a824f6e6bdb7a3e4ccf3f5173100782c94dc9a0462dd8dc6423ef4
|
|
4
|
+
data.tar.gz: b31a6cf4c54563a55844c4fa852ca27804f8ae9d9acb31dfdbcc66d5d58be14c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 --> 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 = "\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']}\"
|
|
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))
|