Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
markdown-it-toc-and-anchor
Advanced tools
markdown-it plugin to add toc and anchor links in headings
markdown-it plugin to add toc and anchor links in headings
$ yarn add markdown-it-toc-and-anchor
import markdownIt from "markdown-it"
import markdownItTocAndAnchor from "markdown-it-toc-and-anchor"
markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItTocAndAnchor, {
// ...options
})
.render(md)
var markdownIt = require('markdown-it'),
markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default;
markdownIt({
html: true,
linkify: true,
typographer: true,
})
.use(markdownItTocAndAnchor, {
// ...options
})
.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:
// ...
slugify : string => `/some/prefix/${string.replace(/(\/| |')/g, "_")}`
// ...
$ npm test
).4.2.0 (2019-01-01)
anchorLinkPrefix
option #27, thanks ruanyfwrapHeadingTextInAnchor
option #28, thanks jsepiaslugify
option, improve example in README, add corresponding test (a085aaf)<a name="4.1.2"></a>
FAQs
markdown-it plugin to add toc and anchor links in headings
The npm package markdown-it-toc-and-anchor receives a total of 20,655 weekly downloads. As such, markdown-it-toc-and-anchor popularity was classified as popular.
We found that markdown-it-toc-and-anchor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.