Valkyrian Labs logo

Table Of Contents

Generate a table of contents from headings in the current Markdown document.

Table Of Contents

Use :::toc to render a table of contents from headings in the current Markdown document.

1:::toc[On this page]{2  depth="3"3  theme="compact"4}5:::

Attributes

  • [Label]: visible TOC title and aria label, preferred for new Markdown
  • title: visible TOC title retained for existing Markdown
  • depth: maximum heading depth from 1 to 6
  • theme: TOC theme name

Defaults:

  • title="On this page"
  • depth="3"
  • theme="default"

Invalid depth values fall back to 3 and produce a non-fatal diagnostic where diagnostics are available.

Heading Anchors

The renderer gives headings stable IDs:

1## Install2 3## Install

Conceptual output:

1<h2 id="install">Install</h2>2<h2 id="install-1">Install</h2>

:::toc links to the same IDs, so heading anchors and TOC entries stay aligned.

Placement

Place :::toc after the H1 and introductory paragraph on long reference pages:

1# Configuration2 3Short introduction.4 5:::toc[On this page]{6  depth="3"7  theme="compact"8}9:::

Themes

Built-in TOC themes:

  • default
  • compact
  • sidebar