Expand description
Table of Contents extraction and Markdown generation.
§Workflow
- Parse the document with
core::parse() - Call
extract_tocto get a flat list ofTocEntryitems - Call
generate_toc_markdownto produce the fenced TOC block - Call
replace_toc_in_textto update or insert the block in the source
Structs§
- TocEntry
- A single entry in the extracted Table of Contents.
Enums§
- TocReplace
Result - Result of attempting to replace an existing TOC block in source text.
Functions§
- extract_
toc - Extract all top-level headings from a document as a flat list of
TocEntryitems. - generate_
toc_ markdown - Generate a Markdown TOC block wrapped in
<!-- TOC -->/<!-- /TOC -->markers. - heading_
slug - Generate a GitHub-compatible URL slug from heading text.
- replace_
toc_ in_ text - Attempt to find and replace an existing
<!-- TOC -->...<!-- /TOC -->block incurrent_textwithnew_toc.