markdown-it-anchor
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@types/markdown-it | 14.1.1 | 71.38 kB | MIT | prod peer | |
markdown-it | 14.1.0 | 749.41 kB | MIT | prod peer |
Markdown-it-anchor is a plugin for the markdown-it library. It enhances the functionality of the library by adding an id
attribute to headings in markdown content. This improves navigation and accessibility of the content by allowing each section to be uniquely referenced. Optionally, it can also add permalinks to these headings, making it easier for users to link to specific sections of the content. Markdown-it-anchor brings improvement to the way markdown content is displayed and navigated, thereby potentially enhancing your website's SEO.
To use the markdown-it-anchor plugin, you first need to install it via npm, and then incorporate it into your JavaScript code. Here's a basic usage example:
const markdownIt = require('markdown-it')();
const markdownItAnchor = require('markdown-it-anchor');
// use the plugin with markdown-it
markdownIt.use(markdownItAnchor, { level: 2 });
// then use markdownIt to convert markdown to HTML
const html = markdownIt.render(yourMarkdownString);
In this example, the plugin is used with a level
option set to 2, meaning that anchors will be applied to all headers except h1
. The opts
object you pass to the use
function allows you to customize the behavior of the plugin; you can set other properties such as permalink
, slugify
, callback
, getTokensText
, tabIndex
, and uniqueSlugStartIndex
to further customize the plugin's behavior.
The documentation for markdown-it-anchor is located on GitHub, specifically in the README file of the project's repository. The README file provides a comprehensive over of the plugin, including its features, how to use it, and how to customize it. For more details, you can check the project on GitHub.