Crate pulldown_cmark_toc
source ·Expand description
Generate a table of contents from a Markdown document.
By default the heading anchor calculation (aka the “slugification”)
is done in a way that attempts to mimic GitHub’s (undocumented) behavior.
(Though you can customize this with your own slug::Slugify
implementation).
§Examples
use pulldown_cmark_toc::TableOfContents;
let text = "# Heading\n\n## Subheading\n\n## Subheading with `code`\n";
let toc = TableOfContents::new(text);
assert_eq!(
toc.to_cmark(),
r#"- [Heading](#heading)
- [Subheading](#subheading)
- [Subheading with `code`](#subheading-with-code)
"#
);
Structs§
- A slugifier that attempts to mimic GitHub’s behavior.
- Represents a heading.
- Configuration options to use when rendering the Table of Contents.
- Represents a Table of Contents.
Enums§
- Which symbol to use when rendering Markdown list items.
Traits§
- A trait to specify the anchor calculation.