{"id":30111104,"url":"https://github.com/rehypejs/rehype-shift-heading","last_synced_at":"2025-09-03T10:33:29.878Z","repository":{"id":45221179,"uuid":"404730471","full_name":"rehypejs/rehype-shift-heading","owner":"rehypejs","description":"plugin to change the rank (depth, level) of headings","archived":false,"fork":false,"pushed_at":"2024-05-22T13:52:35.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-08-09T14:58:19.881Z","etag":null,"topics":["change","hast","heading","move","rehype","rehype-plugin","shift"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","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/rehypejs.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":"2021-09-09T13:21:47.000Z","updated_at":"2024-07-02T12:13:48.000Z","dependencies_parsed_at":"2024-02-09T16:54:00.302Z","dependency_job_id":"3493eaa0-7f9a-49e5-af3c-0d9c9ba37159","html_url":"https://github.com/rehypejs/rehype-shift-heading","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"5bab36b2c635b0206dae642a62898433c30a8e74"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rehypejs/rehype-shift-heading","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-shift-heading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-shift-heading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-shift-heading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-shift-heading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehypejs","download_url":"https://codeload.github.com/rehypejs/rehype-shift-heading/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-shift-heading/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273430553,"owners_count":25104481,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["change","hast","heading","move","rehype","rehype-plugin","shift"],"created_at":"2025-08-10T05:07:25.012Z","updated_at":"2025-09-03T10:33:29.854Z","avatar_url":"https://github.com/rehypejs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# rehype-shift-heading\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**[rehype][]** plugin to change the rank of headings.\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(rehypeShiftHeading[, options])`](#unifieduserehypeshiftheading-options)\n  * [`Options`](#options)\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][] ([rehype][]) plugin to change the rank (also known\nas depth or level) of headings (so `\u003ch1\u003e` through `\u003ch6\u003e`).\nYou can increase (by passing a positive number) or decrease (negative number)\nall headings.\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**rehype** adds support for HTML to unified.\n**hast** is the HTML AST that rehype uses.\nThis is a rehype plugin that changes headings in the tree.\n\n## When should I use this?\n\nThis plugin is particularly useful when merging documents into each other.\nFor example, when injecting a `readme.md` that starts with an `\u003ch1\u003e` into a\nsite that uses an `\u003ch1\u003e` for the title of the website.\nThis plugin can be used to shift all the headings inside the readme.\n\nThis plugin is built on [`hast-util-shift-heading`][hast-util-shift-heading],\nwhich does the work on syntax trees.\nrehype focusses on making it easier to transform content by abstracting such\ninternals away.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install rehype-shift-heading\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeShiftHeading from 'https://esm.sh/rehype-shift-heading@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import rehypeShiftHeading from 'https://esm.sh/rehype-shift-heading@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay our module `example.js` looks as follows:\n\n```js\nimport {rehype} from 'rehype'\nimport rehypeShiftHeading from 'rehype-shift-heading'\n\nconst file = await rehype()\n  .data('settings', {fragment: true})\n  .use(rehypeShiftHeading, {shift: 1})\n  .process('\u003ch1\u003eAlpha!\u003c/h1\u003e')\n\nconsole.log(String(file))\n```\n\nNow, running `node example` yields:\n\n```html\n\u003ch2\u003eAlpha!\u003c/h2\u003e\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeShiftHeading`][api-rehype-shift-heading].\n\n### `unified().use(rehypeShiftHeading[, options])`\n\nChange the rank (depth, level) of headings.\n\nDoes not shift past `h1` and `h6`.\n\n###### Parameters\n\n* `options` ([`Options`][api-options], optional)\n  — configuration\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n* `shift` (`number`, default: `0`)\n  — number to shift headings; can be negative to decrease heading levels\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`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, `rehype-shift-heading@^2`,\ncompatible with Node.js 16.\n\nThis plugin works with `rehype-parse` version 1+, `rehype-stringify` version 1+,\n`rehype` version 1+, and `unified` version 4+.\n\n## Security\n\nUse of `rehype-shift-heading` is safe.\n\n## Related\n\n* [`rehype-slug`](https://github.com/rehypejs/rehype-slug)\n  — add `id`s to headings\n* [`rehype-autolink-headings`](https://github.com/rehypejs/rehype-autolink-headings)\n  — add links to headings\n* [`rehype-headings-normalize`](https://github.com/hashbite/rehype-headings-normalize)\n  — normalizes headlines by shifting to a minimum level and closing gaps\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`rehypejs/.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] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/rehypejs/rehype-shift-heading/workflows/main/badge.svg\n\n[build]: https://github.com/rehypejs/rehype-shift-heading/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-shift-heading.svg\n\n[coverage]: https://codecov.io/github/rehypejs/rehype-shift-heading\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-shift-heading.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-shift-heading\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-shift-heading\n\n[size]: https://bundlejs.com/?q=rehype-shift-heading\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/rehypejs/rehype/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/rehypejs/.github\n\n[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[typescript]: https://www.typescriptlang.org\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[hast-util-shift-heading]: https://github.com/syntax-tree/hast-util-shift-heading\n\n[api-options]: #options\n\n[api-rehype-shift-heading]: #unifieduserehypeshiftheading-options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-shift-heading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehypejs%2Frehype-shift-heading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-shift-heading/lists"}