{"id":23983579,"url":"https://github.com/jamesgeorgewilliams/rehype-wrap-sibling","last_synced_at":"2026-03-11T07:01:19.628Z","repository":{"id":271225428,"uuid":"901913365","full_name":"jamesgeorgewilliams/rehype-wrap-sibling","owner":"jamesgeorgewilliams","description":"A rehype plugin to wrap a selected element and its sibling in a container element.","archived":false,"fork":false,"pushed_at":"2025-05-21T04:34:26.000Z","size":261,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T17:49:38.803Z","etag":null,"topics":["rehype","rehype-plugin","sibling","wrap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rehype-wrap-sibling","language":"TypeScript","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/jamesgeorgewilliams.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-11T14:50:45.000Z","updated_at":"2025-05-21T04:34:23.000Z","dependencies_parsed_at":"2025-02-13T10:29:54.472Z","dependency_job_id":"7bc30f7c-9dbc-400b-be1d-9e402287b8a1","html_url":"https://github.com/jamesgeorgewilliams/rehype-wrap-sibling","commit_stats":null,"previous_names":["jamesgeorgewilliams/rehype-wrap-sibling"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jamesgeorgewilliams/rehype-wrap-sibling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgeorgewilliams%2Frehype-wrap-sibling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgeorgewilliams%2Frehype-wrap-sibling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgeorgewilliams%2Frehype-wrap-sibling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgeorgewilliams%2Frehype-wrap-sibling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesgeorgewilliams","download_url":"https://codeload.github.com/jamesgeorgewilliams/rehype-wrap-sibling/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgeorgewilliams%2Frehype-wrap-sibling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30373505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["rehype","rehype-plugin","sibling","wrap"],"created_at":"2025-01-07T12:18:13.435Z","updated_at":"2026-03-11T07:01:19.610Z","avatar_url":"https://github.com/jamesgeorgewilliams.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rehype-wrap-sibling\n\n![build](https://github.com/jamesgeorgewilliams/rehype-wrap-sibling/workflows/main/badge.svg)\n[![npm version](https://badge.fury.io/js/rehype-wrap-sibling.svg?icon=si%3Anpm)](https://badge.fury.io/js/rehype-wrap-sibling)\n\nA [rehype](https://github.com/rehypejs/rehype?tab=readme-ov-file#plugins) plugin to wrap a selected element and its\nsibling in a container element.\n\n- The plugin will wrap all occurrences of the provided selector and its sibling if one exists.\n- The selected element(s) and next sibling are wrapped by default.\n- HTML comments between the selected element(s) and sibling element will not be preserved.\n- The plugin doesn't prettify output of the wrapper: whitespace, line endings, etc.\n\n## Installation\n\nThis package is [ESM only][esm]. In Node.js (version 18+), install with [npm][]:\n\n```sh\nnpm i rehype-wrap-sibling\n```\n\n## Usage\n\n```js\n/* example.js */\n\nimport * as fs from 'node:fs/promises';\nimport { rehype } from 'rehype';\nimport rehypeWrapSibling from 'rehype-wrap-sibling';\n\nconst document = await fs.readFile('./input.html', 'utf8');\n\nconst file = await rehype()\n\t.data('settings', { fragment: true })\n\t.use(rehypeWrapSibling, {\n\t\tselector: 'h1',\n\t\twrapper: 'hgroup#doc-title',\n\t})\n\t.process(document);\n\nawait fs.writeFile('./output.html', String(file));\n```\n\n```html\n\u003c!-- input.html --\u003e\n\n\u003ch1\u003eHTML: Living Standard\u003c/h1\u003e\n\u003cp\u003eLast Edited: 7 July 2022\u003c/p\u003e\n```\n\n```html\n\u003c!-- output.html --\u003e\n\n\u003chgroup id=\"doc-title\"\u003e\u003ch1\u003eHTML: Living Standard\u003c/h1\u003e\u003cp\u003eLast Edited: 7 July 2022\u003c/p\u003e\u003c/hgroup\u003e\n```\n\n### Options\n\nName | Type | Description\n---|---|---\n`selector` | `string` | CSS selector to select an element(s).\n`wrapper` | `string?` | Element to wrap the selected element and its sibling.\n`wrapPreviousSibling` | `boolean?` | If `true`, the selected element(s), and its previous sibling are wrapped.\n\n- If no `wrapper` option is provided by the user, the default container element will be `\u003cdiv\u003e\u003c/div\u003e`.\n- The `selector` option can be a CSS selector supported\nvia [hast-util-select](https://github.com/syntax-tree/hast-util-select?tab=readme-ov-file#support).\n- The `wrapper` option can be a selector supported\nvia [hast-util-parse-selector](https://github.com/syntax-tree/hast-util-parse-selector/blob/main/readme.md#parameters).\n\n## License\n\n[MIT](./LICENSE) :copyright: [James Williams][author]\n\n\u003c!-- Definitions --\u003e\n\n[author]: https://jameswilliams.dev\n[npm]: https://docs.npmjs.com/cli/install\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesgeorgewilliams%2Frehype-wrap-sibling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesgeorgewilliams%2Frehype-wrap-sibling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesgeorgewilliams%2Frehype-wrap-sibling/lists"}