remark-heading-gap
remark plugin to adjust the gap between headings.
Important!
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+.
Install
npm:
npm install remark-heading-gap
Use
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()
.use(gap)
.processSync(fs.readFileSync('example.md'))
.toString()
console.log(result)
Now, running node example
yields:
# remark-heading-gap
## Example
## API
### `remark.use(headingGap[, options])`
## Contributing
API
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.
Security
Use of remark-heading-gap
does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.
Contribute
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.