Header anchors for markdown-it.
const md =
See a demo as JSFiddle.
opts object can contain:
||Minimum level to apply anchors on or array of selected levels.||1|
||A custom slugification function.||See
||Whether to add permalinks next to titles.||
||A custom permalink rendering function.||See
||The class of the permalink anchor.||
||The symbol in the permalink anchor.||
||Place the permalink before the title.||
||A custom permalink
||Called with token and info after rendering.||
renderPermalink function takes the slug, an options object with
the above options, and then all the usual markdown-it rendering
All headers above
level will then have an
id attribute with a slug
of their content.
level can also be an array of headers levels to
apply the anchor, like
[2, 3] to have an anchor on only level 2 and
¶ symbol linking to the header itself will
You may want to use the link symbol as
permalinkSymbol, or a symbol from your favorite web font.
callback option is a function that will be called at the end of
rendering with the
token and an
info object. The
info object has
slug properties with the token content and the slug used
for the identifier.
markdown-it-anchor dropped package
keeping it's core value of being an unopinionated and secure library. Yet,
users looking for backward compatibility may want the old slugify:
$ npm i -S string
const string =const legacySlugify =const md =const anchor =
Unicode is supported by default. Yet, if you are looking for a "prettier"
--opinionated-- link, i.e without %xx, you may want to take a look at
$ npm i -S uslug
const uslug =const uslugify =const md =const anchor =
Table of Contents
Looking for an automatic table of contents (TOC) generator? Take a look at markdown-it-toc-done-right it's made from the ground to be a great companion of this plugin.