v2.1.0
2.1.0 (2026-04-09)
Features
- pass through attributes on headings (7e46792)
Heading elements with additional attributes will now have those attributes passed through to the generated table of contents. For example, consider the following source HTML with two h2 headings, each with an id and an additional attribute.
<h2 data-highlight="true" id="foo">Foo</h2>
<h2 style="color: red;" id="bar">Bar</h2>Before this change, the output would be the following:
<nav class="toc">
<ol>
<li><a href="#foo">Foo</a></li>
<li><a href="#bar">Bar</a></li>
</ol>
</nav>With this change, the output is now:
<nav class="toc">
<ol>
- <li><a href="#foo">Foo</a></li>
+ <li><a href="#foo" data-highlight="true">Foo</a></li>
- <li><a href="#bar">Bar</a></li>
+ <li><a href="#bar" style="color: red">Bar</a></li>
</ol>
</nav>Fixes
Caution
This patch has been reverted (see v2.1.1) due to issues regarding heading anchor permalinks.
preserve markup within heading content(ca417ad)
Explanation
Markup inside heading elements is now correctly preserved in the table of contents output.
<h2 id="foo"><strong>Foo</strong></h2>
<h3 id="bar">Bar</h3>
<h2 id="baz"><a href="#other">Baz</a></h2>
<h3 id="quz">Qu<a href="#other">z</a></h3>Before this change, the output would be the following:
<nav class="toc">
<ol>
<li>
<a href="#foo">Foo</a>
<ol>
<li><a href="#bar">Bar</a></li>
</ol>
</li>
<li>
<a href="#baz">Baz</a>
<ol>
<li>
<a href="#quz">Quz</a>
</li>
</ol>
</li>
</ol>
</nav>With this change, the output is now:
<nav class="toc">
<ol>
<li>
- <a href="#foo">Foo</a>
+ <a href="#foo"><strong>Foo</strong></a>
<ol>
<li><a href="#bar">Bar</a></li>
</ol>
</li>
<li>
- <a href="#baz">Baz</a>
+ <a href="#baz"><a href="#other">Baz</a></a>
<ol>
<li>
- <a href="#quz">Quz</a>
+ <a href="#quz">Qu<a href="#other">z</a></a>
</li>
</ol>
</li>
</ol>
</nav>