From 4db2d4d78fce509a88e3e801cd53b67cd37bd71a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 9 Dec 2020 14:49:11 +0100 Subject: [PATCH] Suppress enumeration that is part of the headline in ToC Resolves #3757 --- .../files/lib/system/html/toc/HtmlTocItem.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/html/toc/HtmlTocItem.class.php b/wcfsetup/install/files/lib/system/html/toc/HtmlTocItem.class.php index 92b42fe7a8..213a3f35ef 100644 --- a/wcfsetup/install/files/lib/system/html/toc/HtmlTocItem.class.php +++ b/wcfsetup/install/files/lib/system/html/toc/HtmlTocItem.class.php @@ -46,7 +46,15 @@ class HtmlTocItem implements \Countable, \RecursiveIterator { } public function getTitle() { - return $this->title; + return preg_replace_callback('/^\s*(\d+)([\.):]|\s*-)\s*/', function ($matches) { + // Strip of a enumeration prefix if the prefixed number matches + // the current offset within the ToC. + if ($this->getParent() && intval($matches[1]) === ($this->getParent()->position + 1)) { + return ''; + } + + return $matches[0]; + }, $this->title); } public function setParent($parent) { -- 2.20.1