Project: imcuttle/remark-heading-id

Package: remark-heading-id@1.0.0

  1. Dependents: 0
  2. The remark plugin for supporting custom heading id
  1. remark 214
  2. heading 26
  3. id 4


Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

The remark plugin for supporting custom heading id and Default Id

Custom Heading Input

### My Great Heading {#custom-id}

Custom Heading Output

<h3 id="custom-id">My Great Heading</h3>


This package exports no identifiers. The default export is remarkHeaderId.

unified().use(remarkHeadingId[, options])


Configuration (optional).


Whether to add default ids based on the title text (boolean, default: false).


Whether to ensure that the default ids created by options.defaults are unique (boolean, default: true). Only relevant when options.defaults = true. Example:

## heading

### introduction

### argument

## heading

### introduction

### argument

Will generate this output when options.defaults = true and options.uniqueDefaults = true:

<h2 id="heading">heading</h2>
<h3 id="indroduction">indroduction</h3>
<h3 id="argument">argument</h3>
<h2 id="heading-1">heading</h2>
<h3 id="introduction-1">introduction</h3>
<h3 id="argument-1">argument</h3>

Instead of this output, which is generated when options.defaults = true and options.uniqueDefaults = false:

<h2 id="heading">heading</h2>
<h3 id="indroduction">indroduction</h3>
<h3 id="argument">argument</h3>
<h2 id="heading">heading</h2>
<h3 id="introduction">introduction</h3>
<h3 id="argument">argument</h3>

The difference being that the last output contains duplicate ids in the generated html, which are avoided using options.uniqueDefaults = true.

Default Heading Input
### My Great Heading
Default Heading Output
<h3 id="my-great-heading">My Great Heading</h3>



This library is written and maintained by imcuttle, moyuyc95@gmail.com.


MIT - imcuttle 🐟