Skip to content

Commit

Permalink
Fix issue with linkDensity being trated as int
Browse files Browse the repository at this point in the history
  • Loading branch information
fivefilters committed Nov 29, 2024
1 parent a60c59c commit de1b1a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,11 @@ private function rateNodes(array $nodes): DOMDocument|bool
} elseif ($sibling->nodeName === 'p') {
$linkDensity = $sibling->getLinkDensity();
$nodeContent = $sibling->getTextContent(true);
$nodeContentLength = mb_strlen($nodeContent);

if (mb_strlen($nodeContent) > 80 && $linkDensity < 0.25) {
if ($nodeContentLength > 80 && $linkDensity < 0.25) {
$append = true;
} elseif ($nodeContent && mb_strlen($nodeContent) < 80 && $linkDensity === 0 && preg_match('/\.( |$)/', $nodeContent)) {
} elseif ($nodeContentLength > 0 && $nodeContentLength < 80 && $linkDensity < 0.25 && preg_match('/\.( |$)/', $nodeContent)) {
$append = true;
}
}
Expand Down

0 comments on commit de1b1a2

Please sign in to comment.