1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-26 14:08:59 +02:00

allow use more of the two depth levels in table of contents

This commit is contained in:
Peter Gribanov
2019-07-11 18:55:09 +03:00
parent 810f537ab2
commit e0fc6a8342

View File

@@ -25,14 +25,15 @@ foreach ($readMeFile as $lineNumber => $line) {
} }
$tableOfContentsStarted = false; $tableOfContentsStarted = false;
$chaptersFound[] = sprintf('%s [%s](#%s)', if (strlen($matches['depth']) === 2) {
strlen($matches['depth']) === 2 $depth = sprintf(' %s.', ++$manIndex);
? sprintf(' %s.', ++$manIndex) } else {
: ' *' $depth = sprintf(' %s*', str_repeat(' ', strlen($matches['depth']) - 1));
, }
$matches['title'],
preg_replace(['/ /', '/[^-\w]+/'], ['-', ''], strtolower($matches['title'])) $link = preg_replace(['/ /', '/[^-\w]+/'], ['-', ''], strtolower($matches['title']));
);
$chaptersFound[] = sprintf('%s [%s](#%s)', $depth, $matches['title'], $link);
} }
if ($tableOfContentsStarted === true && isset($line[0])) { if ($tableOfContentsStarted === true && isset($line[0])) {
$currentTableOfContentsChapters[] = $line; $currentTableOfContentsChapters[] = $line;