From 959f867eadec99eafefacfb3e4c3e2f6c428df11 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Thu, 22 Feb 2024 12:16:00 +0100 Subject: [PATCH] Add a whitespace before and after each ``. --- .../node/HtmlOutputNodeProcessor.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php index 1009f83048..19e2ec98a8 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php @@ -134,6 +134,22 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor DOMUtil::removeNode($paragraph, true); } + // Add a whitespace before and after each ``. + // 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 -- 2.20.1