if 'contents' in node['classes']:
node.html_tagname = 'nav'
node['classes'].remove('contents')
- node['ids'].remove('contents')
+ # If the TOC has a title, the ID will be different, and in that
+ # case we'll leave it there.
+ if 'contents' in node['ids']: node['ids'].remove('contents')
else:
node.html_tagname = 'aside'
<li><a href="#section-after" id="id8">Section after</a></li>
</ul>
</nav>
+<nav class="m-block m-primary" id="toc-title-to-catch-wrong-assumptions-in-topic-processing">
+<h3>TOC title, to catch wrong assumptions in <code>topic</code> processing</h3>
+<ul>
+<li><a href="#section-title" id="id9">Section title</a><ul>
+<li><a href="#section-title-with-link" id="id10">Section title with link</a></li>
+</ul>
+</li>
+<li><a href="#section-after" id="id11">Section after</a></li>
+</ul>
+</nav>
+<aside class="m-block m-dim">
+<h3>A topic that's not a TOC</h3>
+<p>To catch even more wrong assumptions about <code>topic</code> nodes.</p>
+</aside>
<p>A paragraph.</p>
<blockquote>
A block quote.</blockquote>
<dd>Description of term 2</dd>
</dl>
<section id="section-title">
-<h2><a href="#id6">Section title</a></h2>
+<h2><a href="#id9">Section title</a></h2>
<p>An <em>emphasised text</em>, <strong>strong text</strong> and a <code>literal</code>. Link to
<a href="https://google.com">Google</a>, <a href="#a-heading">the heading below</a> or just an
URL as-is: <a class="m-link-wrap" href="https://mcss.mosra.cz/">https://mcss.mosra.cz/</a>. <a href="mailto:mosra@centrum.cz">E-mail</a>. A footnote
</section>
<hr />
<section id="section-after">
-<h2><a href="#id8">Section after</a></h2>
+<h2><a href="#id11">Section after</a></h2>
<p>Docutils says "Document may not end with a transition", eh.</p>
</section>
<!-- /content -->
.. contents::
:class: m-block m-default
+.. contents:: TOC title, to catch wrong assumptions in ``topic`` processing
+ :class: m-block m-primary
+
+.. topic:: A topic that's not a TOC
+ :class: m-block m-dim
+
+ To catch even more wrong assumptions about ``topic`` nodes.
+
A paragraph.
A block quote.