--- description: Render a table of contents from Wenmode Markdown with heading IDs, TOC helpers, and custom slug generation. --- (recipes-table-of-contents)= # Table of contents ```{rst-class} lead Generate heading IDs, render tables of contents, and customize slug behavior for documentation pages. ``` --- Use the `heading_ids` plugin and register the built-in `TableOfContents` directive renderer when the table of contents should be declared inside the Markdown document. ```python from wenmode import Wenmode from wenmode.directives import TableOfContents from wenmode.plugins import heading_ids from wenmode.rules import AtxHeading, LeafDirective wen = Wenmode( [AtxHeading, LeafDirective], directives=[TableOfContents()], plugins=[heading_ids], ) text = ''' ::toc{min=2 max=3} # Title ## Usage ''' html = wen.render(text) assert '