markdown-heading-id 0.1.0

Filter for `pulldown-cmark` which converts headings with custom ID
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 11.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ShotaroTsuji/markdown-heading-id
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ShotaroTsuji

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

## Heading {#heading-id}

then it is converted into a fragment of HTML below:

<h2 id="heading-id">Heading</h2>

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:

use pulldown_cmark::Parser;
use pulldown_cmark::html::push_html;
use markdown_heading_id::HeadingId;

let parser = Parser::new("## Heading {#heading-id}");
let parser = HeadingId::new(parser);
let mut buf = String::new();
push_html(&mut buf, parser);
assert_eq!(buf.trim_end(), r#"<h2 id="heading-id">Heading</h2>"#);

License: MIT