Skip to content

Commit 4649632

Browse files
committed
only display TOC when there is more than one headline
1 parent efc5ea8 commit 4649632

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Yii Framework 2 apidoc extension Change Log
55
-----------------------
66

77
- Enh #38: Fixed display of default values given as octal or hex notation (hiqsol)
8+
- Enh: Display TOC only if there is more than one headline (cebe)
89

910

1011
2.1.0 November 22, 2016

helpers/ApiMarkdown.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ public function parse($text)
7070
*/
7171
protected function applyToc($content)
7272
{
73-
// generate TOC
74-
if (!empty($this->headings)) {
73+
// generate TOC if there is more than one headline
74+
if (!empty($this->headings) && count($this->headings) > 1) {
7575
$toc = [];
76-
foreach ($this->headings as $heading)
76+
foreach ($this->headings as $heading) {
7777
$toc[] = '<li>' . Html::a(strip_tags($heading['title']), '#' . $heading['id']) . '</li>';
78+
}
7879
$toc = '<div class="toc"><ol>' . implode("\n", $toc) . "</ol></div>\n";
7980
if (strpos($content, '</h1>') !== false)
8081
$content = str_replace('</h1>', "</h1>\n" . $toc, $content);

0 commit comments

Comments
 (0)