From 3178ed479377d6c9930c1d3321c3f3da9ef9a6ca Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 5 Oct 2017 13:32:02 +0200 Subject: [PATCH] Avoid empty paragraphs after headlines --- .../html/input/node/HtmlInputNodeProcessor.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index e36ddfb51b..1d7abc18e2 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -224,11 +224,20 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor { /** @var \DOMNode $node */ $node = $this->getDocument()->getElementsByTagName('body')->item(0)->firstChild; + $hX = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; while ($node) { if ($node->nodeType === XML_ELEMENT_NODE && $node->nodeName === 'woltlab-metacode-marker') { $node = $appendToPreviousParagraph($node); } else if ($node->nodeType === XML_TEXT_NODE) { + if ($node->textContent === "\n" || $node->textContent === "\r\n") { + $sibling = $node->previousSibling; + if ($sibling !== null && in_array($sibling->nodeName, $hX)) { + // ignore this node entirely + $node = $node->nextSibling; + continue; + } + } $node = $appendToPreviousParagraph($node); } -- 2.20.1