summaryrefslogtreecommitdiff
path: root/src/Readability.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-11-14 17:04:49 +0000
committerAndres Rey <[email protected]>2016-11-14 17:04:49 +0000
commitfadc0c437251f797b2c224e97d55b3dec6b7d6cb (patch)
treeff518aafd40d043fdeb8daac1279cd94bf31232c /src/Readability.php
parent8a564266a76bf6f456f16b3512116964348f994b (diff)
Ported last part of node rating, new createNode function
Diffstat (limited to 'src/Readability.php')
-rw-r--r--src/Readability.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Readability.php b/src/Readability.php
index 7fc0d2b..f4e7b86 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -394,4 +394,22 @@ class Readability extends Element implements ReadabilityInterface
{
$this->node->parentNode->replaceChild($newNode->node, $this->node);
}
+
+ /**
+ * Creates a new node based on the text content of the original node.
+ *
+ * @param Readability $originalNode
+ * @param string $tagName
+ *
+ * @return Readability
+ */
+ public function createNode(Readability $originalNode, $tagName)
+ {
+ $text = $originalNode->getTextContent();
+ $newnode = $originalNode->node->ownerDocument->createElement($tagName, $text);
+
+ $return = $originalNode->node->appendChild($newnode);
+
+ return new static($return);
+ }
}