diff options
Diffstat (limited to 'src/HTMLParser.php')
-rw-r--r-- | src/HTMLParser.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 8f00eda..1345bc1 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -1454,11 +1454,18 @@ class HTMLParser private function hasSinglePNode(Readability $node) { // There should be exactly 1 element child which is a P: - // And there should be no text nodes with real content (param true on ->getChildren) - if (count($children = $node->getChildren(true)) !== 1 || !$children[0]->tagNameEqualsTo('p')) { + if (count($children = $node->getChildren()) !== 1 || !$children[0]->tagNameEqualsTo('p')) { return false; } + // And there should be no text nodes with real content (param true on ->getChildren) + foreach ($children as $child) { + /** @var $child Readability */ + if ($child->nodeTypeEqualsTo(XML_TEXT_NODE) && !preg_match('/\S$/', $child->getTextContent())) { + return false; + } + } + return true; } |