Fixed simplified-html adding too many <br>
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Aug 2016 17:05:17 +0000 (19:05 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Aug 2016 17:05:17 +0000 (19:05 +0200)
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php

index b24c0de42a3c88c94614aa1194be0b7585a975d9..8f9dc49abea23b1f46ec76b2b290dd3982dbb004 100644 (file)
@@ -91,6 +91,19 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor {
                                }
                                
                                if (!$isLastNode) {
+                                       // check if paragraph only contains <br>
+                                       if (StringUtil::trim($paragraph->textContent) === '') {
+                                               // get last element
+                                               $element = $paragraph->firstChild;
+                                               while ($element && $element->nodeType !== XML_ELEMENT_NODE) {
+                                                       $element = $element->nextSibling;
+                                               }
+                                               
+                                               if ($element && $element->nodeName === 'br') {
+                                                       $paragraph->removeChild($element);
+                                               }
+                                       }
+                                       
                                        for ($i = 0; $i < 2; $i++) {
                                                $br = $this->getDocument()->createElement('br');
                                                $paragraph->appendChild($br);