From: Tim Düsterhus Date: Wed, 9 Dec 2020 13:49:11 +0000 (+0100) Subject: Suppress enumeration that is part of the headline in ToC X-Git-Tag: 5.4.0_Alpha_1~553^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4db2d4d78fce509a88e3e801cd53b67cd37bd71a;p=GitHub%2FWoltLab%2FWCF.git Suppress enumeration that is part of the headline in ToC Resolves #3757 --- 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) {