summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFiveFilters.org <[email protected]>2021-08-25 03:13:38 +0200
committerFiveFilters.org <[email protected]>2021-08-25 03:13:38 +0200
commit9c1c00e24cb6e06c8678abf8464e61713abfae8d (patch)
tree66670b9dc48150b9c3b81790108223f8ea6cb2b5 /src
parent4fe7aa2a39c12f9dd4bddc8699f76e9bc3eb4b4f (diff)
Renamed nextElement to nextNode
https://github.com/mozilla/readability/commit/60af91f15387fcd5e60fe05212bf6fd1a2d9d36d
Diffstat (limited to 'src')
-rw-r--r--src/Nodes/NodeUtility.php8
-rw-r--r--src/Readability.php6
2 files changed, 9 insertions, 5 deletions
diff --git a/src/Nodes/NodeUtility.php b/src/Nodes/NodeUtility.php
index 88512f2..0e8a3fd 100644
--- a/src/Nodes/NodeUtility.php
+++ b/src/Nodes/NodeUtility.php
@@ -43,13 +43,17 @@ class NodeUtility
];
/**
+ * Finds the next node, starting from the given node, and ignoring
+ * whitespace in between. If the given node is an element, the same node is
+ * returned.
+ *
* Imported from the Element class on league\html-to-markdown.
*
* @param $node
*
- * @return DOMElement
+ * @return DOMNode
*/
- public static function nextElement($node)
+ public static function nextNode($node)
{
$next = $node;
while ($next
diff --git a/src/Readability.php b/src/Readability.php
index 1089769..5a7363d 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -1188,7 +1188,7 @@ class Readability
* or non-whitespace. This leaves behind the first <br> in the chain
* (which will be replaced with a <p> later).
*/
- while (($next = NodeUtility::nextElement($next)) && ($next->nodeName === 'br')) {
+ while (($next = NodeUtility::nextNode($next)) && ($next->nodeName === 'br')) {
$this->logger->debug('[PrepDocument] Removing chain of BR nodes...');
$replaced = true;
@@ -1211,7 +1211,7 @@ class Readability
while ($next) {
// If we've hit another <br><br>, we're done adding children to this <p>.
if ($next->nodeName === 'br') {
- $nextElem = NodeUtility::nextElement($next->nextSibling);
+ $nextElem = NodeUtility::nextNode($next->nextSibling);
if ($nextElem && $nextElem->nodeName === 'br') {
break;
}
@@ -1628,7 +1628,7 @@ class Readability
$this->_cleanExtraParagraphs($article);
foreach (iterator_to_array($article->getElementsByTagName('br')) as $br) {
- $next = NodeUtility::nextElement($br->nextSibling);
+ $next = NodeUtility::nextNode($br->nextSibling);
if ($next && $next->nodeName === 'p') {
$this->logger->debug('[PrepArticle] Removing br node next to a p node.');
$br->parentNode->removeChild($br);