summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-12-10 12:08:52 +0000
committerAndres Rey <[email protected]>2016-12-10 12:08:52 +0000
commit3757f8f838687374e0cb6255928dee83492678f7 (patch)
treed9a59baac6ad4862bcb7f0f9b92653b33a35e7d6 /src
parent1e0cc1cda41d1e9bd223dfba616c4b1351b6934e (diff)
Solved some mistakes during node parsing (before scoring)
Diffstat (limited to 'src')
-rw-r--r--src/HTMLParser.php14
-rw-r--r--src/Readability.php6
2 files changed, 10 insertions, 10 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php
index 01c581b..92a85a4 100644
--- a/src/HTMLParser.php
+++ b/src/HTMLParser.php
@@ -889,12 +889,14 @@ class HTMLParser
private function hasSingleChildBlockElement(Readability $node)
{
- /** @var Readability $child */
- foreach ($node->getChildren() as $child) {
- if (in_array($child->getTagName(), $this->divToPElements)) {
- $this->hasSingleChildBlockElement($child);
- } else {
- return false;
+ if ($node->hasChildren()) {
+ /** @var Readability $child */
+ foreach ($node->getChildren() as $child) {
+ if (in_array($child->getTagName(), $this->divToPElements)) {
+ return true;
+ } else {
+ return $this->hasSingleChildBlockElement($child);
+ }
}
}
diff --git a/src/Readability.php b/src/Readability.php
index d647e63..e3122dd 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -417,11 +417,9 @@ class Readability extends Element implements ReadabilityInterface
public function createNode(Readability $originalNode, $tagName)
{
$text = $originalNode->getTextContent();
- $newnode = $originalNode->node->ownerDocument->createElement($tagName, $text);
+ $newNode = $originalNode->node->ownerDocument->createElement($tagName, $text);
- $return = $originalNode->node->appendChild($newnode);
-
- return new static($return);
+ return new static($newNode);
}
/**