Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fivefilters committed Dec 28, 2021
1 parent 414a160 commit ec7fb4d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Readability.php
Expand Up @@ -250,6 +250,11 @@ public function parse($html)
}
}

if (!$result) {
$this->logger->info('*** Parse failed :(');
return false;
}

$result = $this->postProcessContent($result);

// If we haven't found an excerpt in the article's metadata, use the article's
Expand Down Expand Up @@ -369,6 +374,7 @@ private function getJSONLD(DOMDocument $dom)
$metadata = [];
if (
!isset($parsed['@context']) ||
!is_string($parsed['@context']) ||
!preg_match('/^https?\:\/\/schema\.org$/', $parsed['@context'])
) {
return $metadata;
Expand Down Expand Up @@ -2137,6 +2143,9 @@ private function headerDuplicatesTitle($node) {
if ($node->nodeName !== 'h1' && $node->nodeName !== 'h2') {
return false;
}
if (!isset($this->title)) {
return false;
}
$heading = $node->getTextContent(false);
$this->logger->debug(sprintf('Evaluating similarity of header: %s"', $heading));
return $this->textSimilarity($this->title, $heading) > 0.75;
Expand Down

0 comments on commit ec7fb4d

Please sign in to comment.