yii\apidoc\helpers\ApiMarkdown::applyToc PHP Method

applyToc() protected method

Since: 2.0.5
protected applyToc ( $content )
    protected function applyToc($content)
    {
        // generate TOC
        if (!empty($this->headings)) {
            $toc = [];
            foreach ($this->headings as $heading) {
                $toc[] = '<li>' . Html::a(strip_tags($heading['title']), '#' . $heading['id']) . '</li>';
            }
            $toc = '<div class="toc"><ol>' . implode("\n", $toc) . "</ol></div>\n";
            if (strpos($content, '</h1>') !== false) {
                $content = str_replace('</h1>', "</h1>\n" . $toc, $content);
            } else {
                $content = $toc . $content;
            }
        }
        return $content;
    }