diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Nodes/NodeUtility.php | 8 | ||||
-rw-r--r-- | src/Readability.php | 6 |
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); |