pulldown-cmark-toc

Crates.iopulldown-cmark-toc
lib.rspulldown-cmark-toc
version0.5.0
sourcesrc
created_at2020-08-02 16:13:55.80631
updated_at2024-06-26 08:27:28.419205
descriptionGenerate a table of contents from a Markdown document.
homepage
repositoryhttps://github.com/rossmacarthur/pulldown-cmark-toc
max_upload_size
id272265
size31,320
Ross MacArthur (rossmacarthur)

documentation

README

pulldown-cmark-toc

Crates.io Docs.rs Build Status

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.

Getting started

Add the pulldown-cmark-toc to your Cargo.toml.

cargo add pulldown-cmark-toc

Usage

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)
"#
);
}

License

Licensed under either of

at your option.

Commit count: 31

cargo fmt