From 9ff6e9510b8d2f0e622e1c0959502ef0b6c53f23 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 May 2023 11:58:09 +0200 Subject: [PATCH] Simplify the code to calculate the number of paragraphs to retain --- .../html/output/node/HtmlOutputNodeNormalizer.class.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php index 2ba481cc3b..4bf2fdafab 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeNormalizer.class.php @@ -83,13 +83,8 @@ final class HtmlOutputNodeNormalizer // We need to reduce the number of paragraphs by half, unless it // is an uneven number in which case we need to remove one // additional paragraph. - if ($offset % 2 === 1) { - // 2 -> 1, 4 -> 2 - $numberOfParagraphsToRemove = \ceil($offset / 2); - } else { - // 3 -> 1, 5 -> 2 - $numberOfParagraphsToRemove = \ceil($offset / 2) + 1; - } + $totalNumberOfParagraphs = $offset + 1; + $numberOfParagraphsToRemove = \ceil($totalNumberOfParagraphs / 2); $removeParagraphs = \array_slice($paragraphs, $i, $numberOfParagraphsToRemove); foreach ($removeParagraphs as $paragraph) { -- 2.20.1