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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a1b61ac01f8639dc5ebd9219be2c129f739913aa31b80755985cce993586947
4
- data.tar.gz: '0093eca156a35705d9bed99d33e31f0cfbdb23f4421c844a29b22b8ee17c7a52'
3
+ metadata.gz: 2346d2fb227e1e0e43ccb9ac2402701831df9d73e4dc875c0318d6faf0111477
4
+ data.tar.gz: 374f9b5cb46a851e6309a5b96ae1ae1695cc6c4fe79290a3b3fc2e793f2902c0
5
5
  SHA512:
6
- metadata.gz: 952f8342972eba74060d8302febc3ff5a6f6f1f87de0d5b98ec50a2a0ed9476592a1d32ea195f61c0dd03473611799586e6a59150b2145979d9c76db5b1c92b9
7
- data.tar.gz: 5e277f3a164204f8def9ba19d7e0fc3f85dfc39bf9aaaa25b8fd8110336fa9bb20c74ad796ddb07b35ef48d272a63f48212d1ea0a9767bf9cc1c012a3e54cd42
6
+ metadata.gz: d3c9af48116272e35456017965f7620805163d2b795178ebc0cde82bcea418024cbff08b1ed48d5b408dee829f75dfb536288fc6b5d142fd7527e38f5bcaed59
7
+ data.tar.gz: e1102be75b15b30f39291b15ebbb2250676aeb9e3df6f6c5e4a8817be89f665f3571e707d66f6984fc3fbb80638c24ef27cee1408f1aaee99e7ca6f6fca3c898
@@ -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 = Nokogiri::HTML5("<html><body>#{@attempts[0][:html]}</body></html>")
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 = Nokogiri::HTML5("<html><head></head><body>#{@prepped_body_html}</body></html>")
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(' ')}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Readability
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readability-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Croll