readability-rb 0.8.0 → 0.9.0
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/document.rb +8 -2
- data/lib/readability/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: 2346d2fb227e1e0e43ccb9ac2402701831df9d73e4dc875c0318d6faf0111477
|
|
4
|
+
data.tar.gz: 374f9b5cb46a851e6309a5b96ae1ae1695cc6c4fe79290a3b3fc2e793f2902c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3c9af48116272e35456017965f7620805163d2b795178ebc0cde82bcea418024cbff08b1ed48d5b408dee829f75dfb536288fc6b5d142fd7527e38f5bcaed59
|
|
7
|
+
data.tar.gz: e1102be75b15b30f39291b15ebbb2250676aeb9e3df6f6c5e4a8817be89f665f3571e707d66f6984fc3fbb80638c24ef27cee1408f1aaee99e7ca6f6fca3c898
|
data/lib/readability/document.rb
CHANGED
|
@@ -528,7 +528,7 @@ module Readability
|
|
|
528
528
|
return nil if @attempts[0][:text_length] == 0
|
|
529
529
|
|
|
530
530
|
# Re-parse the best attempt from serialized HTML
|
|
531
|
-
best_doc =
|
|
531
|
+
best_doc = reparse("<html><body>#{@attempts[0][:html]}</body></html>")
|
|
532
532
|
best_doc.root["lang"] = preserved_article_lang if preserved_article_lang
|
|
533
533
|
best_doc.root["dir"] = preserved_article_dir if preserved_article_dir
|
|
534
534
|
article_content = best_doc.at_css("body")
|
|
@@ -538,7 +538,7 @@ module Readability
|
|
|
538
538
|
|
|
539
539
|
unless parse_successful
|
|
540
540
|
# Create a fresh document from the prepped body HTML, allowing the old one to be GC'd
|
|
541
|
-
@doc =
|
|
541
|
+
@doc = reparse("<html><head></head><body>#{@prepped_body_html}</body></html>")
|
|
542
542
|
# Restore the lang attribute on the new HTML element so it's picked up during traversal
|
|
543
543
|
@doc.root["lang"] = preserved_article_lang if preserved_article_lang
|
|
544
544
|
@doc.root["dir"] = preserved_article_dir if preserved_article_dir
|
|
@@ -578,6 +578,12 @@ module Readability
|
|
|
578
578
|
@flags = @flags & ~flag
|
|
579
579
|
end
|
|
580
580
|
|
|
581
|
+
# The page already passed the caller's limits when it was first parsed. Re-parsing
|
|
582
|
+
# adds a few wrapper levels, so don't limit it again.
|
|
583
|
+
def reparse(html)
|
|
584
|
+
Nokogiri::HTML5(html, max_attributes: -1, max_tree_depth: -1)
|
|
585
|
+
end
|
|
586
|
+
|
|
581
587
|
def log(*args)
|
|
582
588
|
return unless @debug
|
|
583
589
|
puts "Reader: (Readability) #{args.map(&:to_s).join(' ')}"
|
data/lib/readability/version.rb
CHANGED