| Crates.io | pulldown-cmark-toc |
| lib.rs | pulldown-cmark-toc |
| version | 0.7.0 |
| created_at | 2020-08-02 16:13:55.80631+00 |
| updated_at | 2025-02-24 07:05:27.564033+00 |
| description | Generate a table of contents from a Markdown document. |
| homepage | |
| repository | https://github.com/rossmacarthur/pulldown-cmark-toc |
| max_upload_size | |
| id | 272265 |
| size | 33,639 |
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.
Add the pulldown-cmark-toc to your Cargo.toml.
cargo add pulldown-cmark-toc
use pulldown_cmark_toc::TableOfContents;
let text = r#"
# Heading
## Subheading
## Subheading with `code`
"#;
let toc = TableOfContents::new(text);
assert_eq!(
toc.to_cmark(),
r#"- [Heading](#heading)
- [Subheading](#subheading)
- [Subheading with `code`](#subheading-with-code)
"#
);
}
Licensed under either of
at your option.