Gathering detailed insights and metrics for markdown-it-toc-and-anchor
Gathering detailed insights and metrics for markdown-it-toc-and-anchor
Gathering detailed insights and metrics for markdown-it-toc-and-anchor
Gathering detailed insights and metrics for markdown-it-toc-and-anchor
markdown-it-github-toc
markdown-it plugin to add toc and anchor links in headings
@hikerpig/markdown-it-toc-and-anchor
markdown-it plugin to add toc and anchor links in headings
markdown-it-toc-and-anchor-fork
markdown-it plugin to add toc and anchor links in headings
@gerhobbelt/markdown-it-toc-and-anchor
markdown-it plugin to add toc and anchor links in headings
markdown-it plugin to add a toc and anchor links in headings
npm install markdown-it-toc-and-anchor
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
7,580,299
Last Day
576
Last Week
19,487
Last Month
90,959
Last Year
1,221,133
MIT License
61 Stars
123 Commits
36 Forks
4 Watchers
173 Branches
9 Contributors
Updated on Jun 19, 2025
Minified
Minified + Gzipped
Latest Version
4.2.0
Package Id
markdown-it-toc-and-anchor@4.2.0
Unpacked Size
30.96 kB
Size
8.31 kB
File Count
6
NPM Version
6.4.1
Node Version
10.15.0
Cumulative downloads
Total Downloads
markdown-it plugin to add toc and anchor links in headings
1$ yarn add markdown-it-toc-and-anchor
1import markdownIt from "markdown-it" 2import markdownItTocAndAnchor from "markdown-it-toc-and-anchor" 3 4markdownIt({ 5 html: true, 6 linkify: true, 7 typographer: true, 8 }) 9 .use(markdownItTocAndAnchor, { 10 // ...options 11 }) 12 .render(md)
1var markdownIt = require('markdown-it'), 2 markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default; 3 4markdownIt({ 5 html: true, 6 linkify: true, 7 typographer: true, 8 }) 9 .use(markdownItTocAndAnchor, { 10 // ...options 11 }) 12 .render(md)
:information_source: Note that the 'default' property has to be used when requiring this plugin, this is due to the use of Babel 6 now making ES6 compliant exports (Misunderstanding ES6 Modules, Upgrading Babel, Tears, and a Solution )
toc
(default: true
)
Allows you to enable/disable the toc transformation of @[toc]
tocClassName
(default: "markdownIt-TOC"
)
Option to customize html class of the <ul>
wrapping the toc. If no class is wanted set to null
.
tocFirstLevel
(default: 1
)
Allows you to skip some heading level. Example: use 2 if you want to skip <h1>
from the TOC.
tocLastLevel
(default: 6
)
Allows you to skip some heading level. Example: use 5 if you want to skip <h6>
from the TOC.
tocCallback
(default: null
)
Allows you to get toc contents externally by executing a callback function returning toc elements, in addition / instead of using @[toc] tag in content. Example :
markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItTocAndAnchor, {
tocCallback: function(tocMarkdown, tocArray, tocHtml) {
console.log(tocHtml)
}
})
.render(md)
To allow callback to be more flexible, this option is also available in global markdown-it options, and in render environment. Example :
var mdIt = markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItTocAndAnchor)
....
mdIt.set({
tocCallback: function(tocMarkdown, tocArray, tocHtml) {
console.log(tocHtml)
}
})
.render(md)
var mdIt = markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItTocAndAnchor)
....
mdIt
.render(md, {
tocCallback: function(tocMarkdown, tocArray, tocHtml) {
console.log(tocHtml)
}
})
anchorLink
(default: true
)
Allows you to enable/disable the anchor link in the headings
anchorLinkSymbol
(default: "#"
)
Allows you to customize the anchor link symbol
anchorLinkSpace
(default: true
)
Allows you to enable/disable inserting a space between the anchor link and heading.
anchorLinkSymbolClassName
(default: null
)
Allows you to customize the anchor link symbol class name. If not null, symbol will be rendered as <span class="anchorLinkSymbolClassName">anchorLinkSymbol</span>
.
anchorLinkBefore
(default: true
)
Allows you to prepend/append the anchor link in the headings
anchorLinkPrefix
(default: undefined
)
Allows you to add a prefix to the generated header ids, e.g. section-
.
anchorClassName
(default: "markdownIt-Anchor"
)
Allows you to customize the anchor link class. If no class is wanted set to null
.
wrapHeadingTextInAnchor
(default: false
)
Makes the entire heading into the anchor link (takes precedence over anchorLinkSymbol
and anchorLinkBefore
)
resetIds
(default: true
)
Allows you to reset (or not) ids incrementation. Use it if you will have multiple documents on the same page.
slugify
(default: uses the uslug
package)
Allows you to customize the slug function that create ids from string.
Ex:
1 // ... 2 slugify : string => `/some/prefix/${string.replace(/(\/| |')/g, "_")}` 3 // ...
$ npm test
).7.5/10
Summary
Denial of Service in markdown-it-toc-and-anchor
Affected Versions
< 4.2.0
Patched Versions
4.2.0
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
65 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
-26.9%
576
Compared to previous day
Last Week
-12.5%
19,487
Compared to previous week
Last Month
-12.9%
90,959
Compared to previous month
Last Year
15.7%
1,221,133
Compared to previous year