summaryrefslogtreecommitdiff
path: root/src/HTMLParser.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTMLParser.php')
-rw-r--r--src/HTMLParser.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php
index 21bb88f..5a684a5 100644
--- a/src/HTMLParser.php
+++ b/src/HTMLParser.php
@@ -438,7 +438,8 @@ class HTMLParser
$append = false;
// TODO Check if this comparison working as expected
- if ($sibling === $topCandidate) {
+ // On the original js project it was a simple $sibling == $topCandidate comparison.
+ if ($this->compareNodes($sibling, $topCandidate)) {
$append = true;
} else {
$contentBonus = 0;
@@ -473,7 +474,7 @@ class HTMLParser
// $sibling->setNodeName('div');
}
- $import = $articleContent->importNode($sibling->getDOMNode());
+ $import = $articleContent->importNode($sibling->getDOMNode(), true);
$articleContent->appendChild($import);
}
}
@@ -504,4 +505,17 @@ class HTMLParser
}
return false;
}
+
+ private function compareNodes($node1, $node2)
+ {
+ if ($node1->getTagName() !== $node2->getTagName()) {
+ return false;
+ }
+
+ if ($node1->getTextContent() !== $node2->getTextContent()) {
+ return false;
+ }
+
+ return true;
+ }
}