diff options
author | Andres Rey <[email protected]> | 2017-11-05 12:53:38 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-11-05 12:53:38 +0000 |
commit | da1d209d9feac2b7bc4d01baf42b75eddd0e56e0 (patch) | |
tree | 1c34fc72c6ec4a1826078d779953ba824acbc128 | |
parent | 701748db8c5d373cc297257915d497d3ae61b2d1 (diff) |
Check for text node contents before converting them to P tags
-rw-r--r-- | src/HTMLParser.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 14dfa59..4e6219e 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -684,12 +684,9 @@ class HTMLParser // EXPERIMENTAL foreach ($node->getChildren() as $child) { /** @var Readability $child */ - if ($child->isText()) { - // Check if there's actual content on the node. - if (trim($child->getTextContent())) { - $newNode = $node->createNode($child, 'p'); - $child->replaceChild($newNode); - } + if ($child->isText() && mb_strlen(trim($child->getTextContent())) > 0) { + $newNode = $node->createNode($child, 'p'); + $child->replaceChild($newNode); } } } |