Header 1

The div element cannot be ...">

Allow TOC element to be fully customizable · Issue #1293 · Python-Markdown/markdown (original) (raw)

will currently generate the following HTML:

<div class="toc">
  <ul>
    <li><a href="#header-1">Header 1</a></li>
  </ul>
</div>
<h1 id="header-1">Header 1</h1>

The div element cannot be changed and so it is for the title span element and its toctitle class.

I suggest that other config parameters (toc_tag, title_class, title_tag) that defaults to their current defaults are introduced.

This would be very useful for producing semantic HTML, using specific HMTL elements.

For example to use the details disclosure element as toc, the extension could be called like so:

md = markdown.Markdown(extensions=[TocExtension(
    title='Summary',
    title_class="",
    title_tag="summary",
    toc_class="",
    toc_tag="details"
)]]
<details>
<summary>Summary</summary>
<ul>
<li><a href="#header">Header</a></li>
</ul>
</details>
<h1 id="header">Header</h1>

This will render an initially closed details element with a summary:


Summary