# markdown-it-heading-anchors.rs [crates.io](https://crates.io/crates/markdown-it-heading-anchors) A [markdown-it.rs](https://crates.io/crates/markdown-it) plugin that adds an id attribute to headings and optionally permalinks. The default behaviour is designed to imitate GitHub's heading anchors as closely as possible, but it can be configured to suit your needs. ## Usage ```rust let parser = &mut markdown_it::MarkdownIt::new(); markdown_it::plugins::cmark::add(md); markdown_it_heading_anchors::add(parser); parser.parse("# Heading").render(); //

Head

``` ## Options To change the default options, use the `add_with_options` function: ```rust use markdown_it_heading_anchors::{ add_with_options, HeadingAnchorOptions, AnchorPosition }; let parser = &mut markdown_it::MarkdownIt::new(); markdown_it::plugins::cmark::add(md); let mut options = HeadingAnchorOptions::default(); options.position = AnchorPosition::After; options.inner_html = String::from("¶"); add_with_options(parser, options); parser.parse("# Heading").render(); //

Heading

``` Available options: | Name | Type | Default | Description | | ---- | ---- | ------- | :---------- | | `min_level` | `u8` | 1 | Minimum heading level to add anchors to. | | `max_level` | `u8` | 6 | Maximum heading level to add anchors to. | | `id_on_heading` | `bool` | `false` | Whether to add the id attribute to the heading. | | `position` | `AnchorPosition` | `::Start` | Where to place the anchor in the heading children | | `classes` | `Vec` | `["anchor"]` | Classes to add to the anchor. | | `inner_html` | `String` | see example | HTML to add inside the anchor (i.e. the icon). | ## TODO - Ignore alt text in images (also custom "textify"?). - Allow for customizing the slug generation function. - Allow for prefixing the `id` attribute. ## Acknowledgements Adapted from and (see also ).