{"id":28573693,"url":"https://github.com/remarkjs/remark-heading-gap","last_synced_at":"2025-06-10T21:19:27.743Z","repository":{"id":46187326,"uuid":"49831039","full_name":"remarkjs/remark-heading-gap","owner":"remarkjs","description":"plugin to adjust the gap between headings in markdown","archived":false,"fork":false,"pushed_at":"2023-09-23T14:31:41.000Z","size":100,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-01T05:48:53.472Z","etag":null,"topics":["gap","heading","remark","remark-plugin","whitespace"],"latest_commit_sha":null,"homepage":"https://unified.js.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remarkjs.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-17T19:03:30.000Z","updated_at":"2024-05-24T05:11:33.000Z","dependencies_parsed_at":"2024-06-18T22:43:09.262Z","dependency_job_id":null,"html_url":"https://github.com/remarkjs/remark-heading-gap","commit_stats":{"total_commits":100,"total_committers":3,"mean_commits":"33.333333333333336","dds":"0.31999999999999995","last_synced_commit":"40b237a6be9962418a7e920d51a33d8003dc4bdc"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-heading-gap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-heading-gap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-heading-gap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-heading-gap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkjs","download_url":"https://codeload.github.com/remarkjs/remark-heading-gap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkjs%2Fremark-heading-gap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259152784,"owners_count":22813227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gap","heading","remark","remark-plugin","whitespace"],"created_at":"2025-06-10T21:19:04.482Z","updated_at":"2025-06-10T21:19:27.724Z","avatar_url":"https://github.com/remarkjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# remark-heading-gap\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[remark][]** plugin to adjust the gap between headings in markdown.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`unified().use(remarkHeadingGap[, options])`](#unifieduseremarkheadinggap-options)\n    *   [`Gap`](#gap)\n    *   [`Options`](#options)\n*   [Examples](#examples)\n    *   [Example: blank lines around first/last headings](#example-blank-lines-around-firstlast-headings)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a [unified][] ([remark][]) plugin that lets you change the gap\n(number of blank lines) between headings and surrounding text when formatting\nmarkdown.\n\n## When should I use this?\n\nThis project is useful when you want to adjust the gap around headings when\nformatting markdown.\nFor example, when you want two blank lines before headings with a rank of 2\n(`## Like so`).\nFrom personal experience, adding extra blank lines helps visualize breaks in\nsections, especially when quickly scanning documentation.\nThe default when serializing markdown with `remark-stringify` is to always\nbut a single blank line between blocks (headings, paragraphs, lists, code, etc).\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install remark-heading-gap\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport remarkHeadingGap from 'https://esm.sh/remark-heading-gap@6'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import remarkHeadingGap from 'https://esm.sh/remark-heading-gap@6?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay we have the following file `example.md`:\n\n```markdown\n# Pluto\n\n## Contents\n\n## History\n\n### Discovery\n\n### Name and symbol\n\n### Planet X disproved\n\n## Orbit\n```\n\n…and a module `example.js`:\n\n```js\nimport {remark} from 'remark'\nimport remarkHeadingGap from 'remark-heading-gap'\nimport {read} from 'to-vfile'\n\nconst file = await remark()\n  .use(remarkHeadingGap)\n  .process(await read('example.md'))\n\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```markdown\n# Pluto\n\n\n## Contents\n\n\n## History\n\n### Discovery\n\n### Name and symbol\n\n### Planet X disproved\n\n\n## Orbit\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`remarkHeadingGap`][api-remark-heading-gap].\n\n### `unified().use(remarkHeadingGap[, options])`\n\nAdjust the gap between headings.\n\nThere are no blank lines added if a heading is the first or last child of\nthe document, list item, or block quote.\nFor example, pass `{1: {before: 2, after: 2}}` to add two blank lines before\nand after the main heading.\nYou can also set values to `0` to not add blank lines.\n\n###### Parameters\n\n*   `options` ([`Options`][api-options], default: `{2: {before: 2}}`)\n    — configuration\n\n###### Returns\n\nNothing (`undefined`).\n\n### `Gap`\n\nGap between a heading (TypeScript type).\n\n###### Fields\n\n*   `after` (`number`, default: `1`)\n    — blank lines after heading\n*   `before` (`number`, default: `1`)\n    — blank lines before heading\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Type\n\n```ts\ntype Options = Partial\u003cRecord\u003c1 | 2 | 3 | 4 | 5 | 6, Gap | null | undefined\u003e\u003e\n```\n\n## Examples\n\n### Example: blank lines around first/last headings\n\nThis example shows that there are no blank lines added before the first and\nafter the last heading in a container.\nAssuming we had `example.md` from before and changed it to contain this:\n\n```markdown\n# Alpha\n\nBravo charlie.\n\n\u003e ## Delta\n\u003e\n\u003e Echo foxtrott.\n\u003e\n\u003e ## Golf\n```\n\nThen configuring this plugin in `example.js` like so:\n\n```diff\n@@ -3,7 +3,10 @@ import remarkHeadingGap from 'remark-heading-gap'\n import {read} from 'to-vfile'\n\n const file = await remark()\n-  .use(remarkHeadingGap)\n+  .use(remarkHeadingGap, {\n+    1: {after: 3, before: 3},\n+    2: {after: 2, before: 2}\n+  })\n   .process(await read('example.md'))\n\n console.log(String(file))\n```\n\nThen when running `node example.js` we’d get:\n\n```markdown\n# Alpha\n\n\n\nBravo charlie.\n\n\u003e ## Delta\n\u003e\n\u003e\n\u003e Echo foxtrott.\n\u003e\n\u003e\n\u003e ## Golf\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Gap`][api-gap] and [`Options`][api-options].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `remark-heading-gap@^6`,\ncompatible with Node.js 16.\n\nThis plugin works with `remark-stringify` version 9+ (`remark` version 13+).\nVersion 3 of this plugin worked with `remark-stringify` version 8- (`remark`\nversion 12-).\n\n## Security\n\nUse of `remark-heading-gap` does not involve **[rehype][]** (**[hast][]**) or\nuser content so there are no openings for [cross-site scripting\n(XSS)][wiki-xss] attacks.\n\n## Related\n\n*   [`remarkjs/remark-normalize-headings`](https://github.com/remarkjs/remark-normalize-headings)\n    — make sure there is a single top level heading in a document by adjusting\n    heading ranks accordingly\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Ben Briggs][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/remarkjs/remark-heading-gap/workflows/main/badge.svg\n\n[build]: https://github.com/remarkjs/remark-heading-gap/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-heading-gap.svg\n\n[coverage]: https://codecov.io/github/remarkjs/remark-heading-gap\n\n[downloads-badge]: https://img.shields.io/npm/dm/remark-heading-gap.svg\n\n[downloads]: https://www.npmjs.com/package/remark-heading-gap\n\n[size-badge]: https://img.shields.io/bundlejs/size/remark-heading-gap\n\n[size]: https://bundlejs.com/?q=remark-heading-gap\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/remarkjs/remark/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[health]: https://github.com/remarkjs/.github\n\n[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/remarkjs/.github/blob/main/support.md\n\n[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: http://beneb.info\n\n[hast]: https://github.com/syntax-tree/hast\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[remark]: https://github.com/remarkjs/remark\n\n[typescript]: https://www.typescriptlang.org\n\n[unified]: https://github.com/unifiedjs/unified\n\n[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[api-gap]: #gap\n\n[api-options]: #options\n\n[api-remark-heading-gap]: #unifieduseremarkheadinggap-options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkjs%2Fremark-heading-gap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkjs%2Fremark-heading-gap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkjs%2Fremark-heading-gap/lists"}