New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-headinganchor

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-headinganchor

markdown-it plugin that adds an anchor (i.e., ``) to headings.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by8%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status NPM version Coverage Status

markdown-it-headinganchor

This is a markdown-it plugin that adds an anchor (i.e., <a name=\"blah\"...>) to headings.

There are other plugins that add an id attribute (valeriangalliat/markdown-it-anchor) or name attribute (leff/markdown-it-named-headers) to headings, but neither of these approches work for adding anchors that are not stripped out of email.

So this extension renders from this...

# My Heading
...
[Link to that heading](#MyHeading).

...to this:

<h1 id="MyHeading">
  <a name="MyHeading" class="markdown-it-headinganchor" href="#"></a>
  My Heading
</h1>
...
<p>
  <a href="#MyHeading">Link to that heading</a>.
</p>

To refer to in heading anchor in a link, remove all spaces from the original text. So, for example, you might have:

## `code` is **bold**
...
[link to the heading](#`code`is**bold**)

Much like other markdown-it plugins, the usage is:

var md = require('markdown-it')();
md.use(require('markdown-it-headinganchor'), {
  anchorClass: 'my-class-name', // default: 'markdown-it-headinganchor'
  addHeadingID: true,           // default: true
  addHeadingAnchor: true,       // default: true
  slugify: function(str, md) {} // default: 'My Heading' -> 'MyHeading'
});
md.render('# My Heading');

Originally developed for use with Markdown Here.

Keywords

FAQs

Package last updated on 14 May 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc