Add a whitespace before and after each `<wcfNode-*>`.
authorCyperghost <olaf_schmitz_1@t-online.de>
Thu, 22 Feb 2024 11:16:00 +0000 (12:16 +0100)
committerOlaf Braun <info@braun-development.de>
Thu, 7 Mar 2024 15:37:00 +0000 (16:37 +0100)
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php

index 1009f83048d93bd6ad9dc5706893cf3729c13233..19e2ec98a8f89cb44b3eb7c5debf24e12f3a6933 100644 (file)
@@ -134,6 +134,22 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor
 
                 DOMUtil::removeNode($paragraph, true);
             }
+            // Add a whitespace before and after each `<wcfNode-*>`.
+            // This is necessary to avoid concatenation with neighbouring text.
+            foreach ($this->getXPath()->query('//*') as $childNode) {
+                if (!\str_starts_with($childNode->nodeName, 'wcfNode-')) {
+                    continue;
+                }
+
+                $childNode->parentNode->insertBefore(
+                    $this->getDocument()->createTextNode(" "),
+                    $childNode
+                );
+                $childNode->parentNode->insertBefore(
+                    $this->getDocument()->createTextNode(" "),
+                    $childNode->nextSibling
+                );
+            }
 
             if ($this->outputType === 'text/plain') {
                 // remove all `\n` first