Skip to content

Table of Contents Generation

Markdom can automatically generate a Table of Contents (TOC) by analyzing the headings in your Markdown document. This is especially helpful for longer content, enabling users to navigate easily between sections.

To insert a TOC, add the placeholder <!-- TOC-HERE --> anywhere in your Markdown file. Markdom will replace this comment with a structured HTML navigation element based on the headings it detects.

# Introduction
<!-- TOC-HERE -->
## Getting Started
## Features
<h1 id="introduction">
<a href="#introduction">Introduction</a>
</h1>
<nav class="markdown-toc">
<ul>
<li><a href="#getting-started">Getting Started</a></li>
<li><a href="#features">Features</a></li>
</ul>
</nav>
<h2 id="getting-started">
<a href="#getting-started">Getting Started</a>
</h2>
<h2 id="features">
<a href="#features">Features</a>
</h2>

The TOC is rendered as:

<nav class="markdown-toc">
<ul>
<li><a href="#heading">Heading</a></li>
<!-- More list items for each heading -->
</ul>
</nav>