Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-autolink-headings

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-autolink-headings

Automatically add links to headings in Markdown.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-16.92%
Maintainers
1
Weekly downloads
 
Created
Source

Automatically add links to headings in Markdown.

Install

With npm do:

npm install remark-autolink-headings --save

Example

remark-autolink-headings is designed to work with remark-html & remark-slug, and creates GitHub style links for each of your headings:

var remark   = require('remark');
var html     = require('remark-html');
var slug     = require('remark-slug');
var headings = require('remark-autolink-headings');

var markdown = '# Hello';
var result   = remark().use([ slug, headings, html ]).process(markdown);
console.log(result);

//=> <h1 id="hello"><a href="#hello" aria-hidden="true"><span class="icon icon-link"></span></a>Hello</h1>

Note that this module must be included after remark-slug.

API

remark.use(headings, [options])

options
attributes

Type: object

By default, when using the append or prepend behaviour, this will add aria-hidden="false" to the anchor. When using the wrap behaviour, this is left empty for you to add any extra HTML attributes.

behaviour

Type: string Default: prepend

Set this to prepend to inject the link before the heading text; append after it, and wrap to wrap the whole heading text with the link. Note that the wrap option doesn't apply any value set by the template option.

template

Type: string Default: <span class="icon icon-link"></span>

The template used by the append & prepend behaviours.

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs

Keywords

FAQs

Package last updated on 13 Jun 2016

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