diff options
author | Andres Rey <[email protected]> | 2016-11-13 11:42:43 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2016-11-13 11:42:43 +0000 |
commit | 572ee51c33b27f4e8e0e945d862d5fddf34a36e2 (patch) | |
tree | 9f1d2c2ff0cb329c328d327f22c9fc62fd6748b8 /src/Readability.php | |
parent | 1490fc0ed8422f117fbc2a1a99039993a2161297 (diff) |
Bunch of changes imported from JS project.
Moved hasSinglePElement to HTMLParser, removed the interface declaration.
New hasSingleChildBlockElement function on HTMLParser
Diffstat (limited to 'src/Readability.php')
-rw-r--r-- | src/Readability.php | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/Readability.php b/src/Readability.php index 37ac790..8f7954a 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -74,28 +74,6 @@ class Readability extends Element implements ReadabilityInterface } /** - * Checks if the current node has a single child and if that child is a P node. - * Useful to convert <div><p> nodes to a single <p> node and avoid confusing the scoring system since div with p - * tags are, in practice, paragraphs. - * - * @return bool - */ - public function hasSinglePNode() - { - if ($this->hasChildren()) { - $children = $this->getChildren(); - - if (count($children) === 1) { - if (strtolower($children[0]->getTagName()) === 'p') { - return true; - } - } - } - - return false; - } - - /** * Get the ancestors of the current node. * * @param int $maxLevel Max amount of ancestors to get. @@ -391,4 +369,15 @@ class Readability extends Element implements ReadabilityInterface return true; } + + /** + * Replaces child node with a new one. + * + * @param Readability $newNode + * + */ + public function replaceChild(Readability $newNode) + { + $this->node->parentNode->replaceChild($newNode->node, $this->node); + } } |