Functions
extract_toc_structure
Parse TOC HTML into structured data for custom rendering.
Handles both nested <ul> structures (pyt…
extract_toc_structure
def extract_toc_structure(toc_html: str) -> list[dict[str, Any]]
Parse TOC HTML into structured data for custom rendering.
Handles both nested <ul> structures (python-markdown style) and flat lists (mistune style). For flat lists from mistune, parses indentation to infer heading levels.
This is a standalone function so it can be called from Page.toc_items property for lazy evaluation.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
toc_html |
str |
— | HTML table of contents |
Returns
List of TOC items with id, title, and level (1=H2, 2=H3, 3=H4, etc.)list[dict[str, Any]]
—