pulldown-cmark-toc 0.2.0

Generate a table of contents from a Markdown document.
Documentation

pulldown-cmark-toc

Crates.io Version Docs.rs Latest Build Status

Generate a table of contents from a Markdown document.

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.