Expand description
Add id attribute (slug) to headings.
use markdown_it_heading_anchors::{
add_with_options, HeadingAnchorOptions, AnchorPosition
};
let md = &mut markdown_it::MarkdownIt::new();
markdown_it::plugins::cmark::add(md);
let mut options = HeadingAnchorOptions::default();
options.position = AnchorPosition::Start;
options.inner_html = String::from("¶");
add_with_options(md, options);
assert_eq!(
md.parse("# heading\n\n# heading").render(),
"<h1>\
<a aria-hidden=\"true\" class=\"anchor\" id=\"heading\" href=\"#heading\">¶</a>\
heading</h1>\n\
<h1>\
<a aria-hidden=\"true\" class=\"anchor\" id=\"heading-1\" href=\"#heading-1\">¶</a>\
heading</h1>\n",
);
Structs§
- Heading
Anchor - AST node for a heading anchor
- Heading
Anchor Options - Options for the heading anchor plugin.
Enums§
- Anchor
Position - Where to add the anchor, within the heading children.
Functions§
- add
- Add the heading anchor plugin to MarkdownIt.
- add_
with_ options - Add the heading anchor plugin to MarkdownIt, with options.