summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-12-10 19:27:10 +0000
committerAndres Rey <[email protected]>2016-12-10 19:27:10 +0000
commit532b011de418c5ac5d152150c393aff6495cd0d4 (patch)
tree4d96c71c826fa169a79cf3cfcd6af58c9d92cfa5 /src
parentc7351d93ef2828e88aad20d44051a16fedf6a339 (diff)
Small fix to avoid adding empty DOMText nodes to the selected nodes.
Diffstat (limited to 'src')
-rw-r--r--src/HTMLParser.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php
index 5b2aa2f..9d00b26 100644
--- a/src/HTMLParser.php
+++ b/src/HTMLParser.php
@@ -329,8 +329,11 @@ class HTMLParser
foreach ($node->getChildren() as $child) {
if ($child->isText()) {
/** @var Readability $child */
- $newNode = $node->createNode($child, 'p');
- $child->replaceChild($newNode);
+ // Check if there's actual content on the node but leave crlfs.
+ if (trim($child->getTextContent(), " \t\0\x0B")) {
+ $newNode = $node->createNode($child, 'p');
+ $child->replaceChild($newNode);
+ }
}
}
}