Project: remarkjs/remark-heading-gap

Package: remark-heading-gap@4.0.0

  1. Dependencies: 0·Dependents: 3
  2. remark plugin to adjust the gap between headings
  1. remark 187
  2. unified 164
  3. markdown 130
  4. plugin 127
  5. mdast 87
  6. remark-plugin 69
  7. heading 25
  8. whitespace 6
  9. space 3


Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to adjust the gap between headings.


This plugin is affected by the new parser in remark (micromark, see remarkjs/remark#536). Use version 3 while you’re still on remark 12. Use version 4 for remark 13+.



npm install remark-heading-gap


Say we have a Markdown file, example.md, that looks as follows:

# remark-heading-gap

## Example

## API

### `remark.use(headingGap[, options])`

## Contributing

And our script, example.js, contains:

const fs = require('fs')
const remark = require('remark')
const gap = require('remark-heading-gap')

const result = remark()


Now, running node example yields:

# remark-heading-gap

## Example

## API

### `remark.use(headingGap[, options])`

## Contributing


remark().use(headingGap[, options])

Adjust the gap between headings. Ensures that automatically generated Markdown follows your own rules for blank lines between section headings. From personal experience, adding extra newlines helps to visualize breaks in sections, especially when quickly scanning documentation.

options.{1, 2, 3, 4, 5, 6}

Pass a gap (Object, default: {before: 2, after: 1} for options.2, {before: 1, after: 1} for all others) Customize the gap that appears for up to 6 levels of heading; for example, pass {1: {before: 2, after: 2}} to add two blank lines before and after the first heading. You can also set values to 0, to not add a blank line. There are no blank lines added if a heading is the first or last child of the document, list item, or block quote.


Use of remark-heading-gap does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.


See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Ben Briggs