markdown-heading-id

Filter for the Parser of crate pulldown-cmark

This crate provides a filter of Parser which converts headings with custom ID into HTML. It uses the syntax of headings IDs defined in Extended Syntax of Markdown.

For example, if we have the following fragment of Markdown ```rust

Heading {#heading-id}

then it is converted into a fragment of HTML below: rust

Heading

```

Usage

It is easy to use a filter provided by this crate. HeadingId wraps an instance of Parser and it can be passed to push_html or write_html, because HeadingId implements the trait Iterator<Item=Event<'a>>. An example is given below: ```rust use pulldowncmark::Parser; use pulldowncmark::html::pushhtml; use markdownheading_id::HeadingId;

let parser = Parser::new("## Heading {#heading-id}"); let parser = HeadingId::new(parser); let mut buf = String::new(); pushhtml(&mut buf, parser); asserteq!(buf.trim_end(), r#"

Heading

"#); ```

License: MIT