diff --git a/src/Readability.php b/src/Readability.php index 73076e3..c37c9b6 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -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; } }