{"id":13339473,"url":"https://github.com/agentofuser/rehype-section","last_synced_at":"2025-04-15T01:38:19.377Z","repository":{"id":34903783,"uuid":"188396824","full_name":"agentofuser/rehype-section","owner":"agentofuser","description":"Wraps headings and their contents in `\u003csection\u003e` elements.","archived":false,"fork":false,"pushed_at":"2023-01-07T05:46:09.000Z","size":4540,"stargazers_count":7,"open_issues_count":46,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T21:14:16.713Z","etag":null,"topics":["rehype","rehype-plugin","typescript","typescript-library","unist"],"latest_commit_sha":null,"homepage":"https://npm.im/@agentofuser/rehype-section","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agentofuser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://interplanetarygatsby.com/patrons/"}},"created_at":"2019-05-24T09:48:18.000Z","updated_at":"2024-11-01T02:33:30.000Z","dependencies_parsed_at":"2023-01-15T10:08:22.998Z","dependency_job_id":null,"html_url":"https://github.com/agentofuser/rehype-section","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentofuser%2Frehype-section","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentofuser%2Frehype-section/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentofuser%2Frehype-section/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentofuser%2Frehype-section/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agentofuser","download_url":"https://codeload.github.com/agentofuser/rehype-section/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248990518,"owners_count":21194765,"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":["rehype","rehype-plugin","typescript","typescript-library","unist"],"created_at":"2024-07-29T19:20:03.724Z","updated_at":"2025-04-15T01:38:19.361Z","avatar_url":"https://github.com/agentofuser.png","language":"TypeScript","readme":"# rehype-section\n\n[![Downloads][downloads-badge]][downloads] [![Chat][chat-badge]][chat]\n\nWraps headings and their contents in `\u003csection\u003e` elements.\n\n## Installation\n\n[npm][]:\n\n```bash\nnpm install @agentofuser/rehype-section\n```\n\n## Usage\n\nSay we have the following file, `fragment.html`:\n\n\u003c!-- prettier-ignore --\u003e\n```html\n\u003ch1\u003eh1\u003c/h1\u003e\n  \u003ch2\u003eh2a\u003c/h2\u003e\n    \u003ch3\u003eh3ai\u003c/h3\u003e\n      \u003cp\u003etext3ai\u003c/p\u003e\n    \u003ch3\u003eh3aj\u003c/h3\u003e\n      \u003cp\u003etext3aj\u003c/p\u003e\n  \u003ch2\u003eh2b\u003c/h2\u003e\n    \u003ch3\u003eh3bi\u003c/h3\u003e\n      \u003ch4\u003eh4bix\u003c/h4\u003e\n        \u003cp\u003etext4bix\u003c/p\u003e\n  \u003ch2\u003eh2c\u003c/h2\u003e\n    \u003ch3\u003eh3ci\u003c/h3\u003e\n      \u003cp\u003etext3ci\u003c/p\u003e\n```\n\nAnd our script, `example.js`, looks as follows:\n\n```javascript\nvar fs = require('fs')\nvar rehype = require('rehype')\nvar section = require('rehype-section')\n\nrehype()\n  .data('settings', { fragment: true })\n  .use(section)\n  .process(fs.readFileSync('fragment.html'), function(err, file) {\n    if (err) throw err\n    console.log(String(file))\n  })\n```\n\nNow, running `node example` yields:\n\n\u003c!-- prettier-ignore --\u003e\n```html\n\u003csection class=\"h0Wrapper headingWrapper\"\u003e\n  \u003csection class=\"h1Wrapper headingWrapper\"\u003e\n    \u003ch1\u003eh1\u003c/h1\u003e\n    \u003csection class=\"h2Wrapper headingWrapper\"\u003e\n      \u003ch2\u003eh2a\u003c/h2\u003e\n      \u003csection class=\"h3Wrapper headingWrapper\"\u003e\n        \u003ch3\u003eh3ai\u003c/h3\u003e\n        \u003cp\u003etext3ai\u003c/p\u003e\n      \u003c/section\u003e\n      \u003csection class=\"h3Wrapper headingWrapper\"\u003e\n        \u003ch3\u003eh3aj\u003c/h3\u003e\n        \u003cp\u003etext3aj\u003c/p\u003e\n      \u003c/section\u003e\n    \u003c/section\u003e\n    \u003csection class=\"h2Wrapper headingWrapper\"\u003e\n      \u003ch2\u003eh2b\u003c/h2\u003e\n      \u003csection class=\"h3Wrapper headingWrapper\"\u003e\n        \u003ch3\u003eh3bi\u003c/h3\u003e\n        \u003csection class=\"h4Wrapper headingWrapper\"\u003e\n          \u003ch4\u003eh4bix\u003c/h4\u003e\n          \u003cp\u003etext4bix\u003c/p\u003e\n        \u003c/section\u003e\n      \u003c/section\u003e\n    \u003c/section\u003e\n    \u003csection class=\"h2Wrapper headingWrapper\"\u003e\n      \u003ch2\u003eh2c\u003c/h2\u003e\n      \u003csection class=\"h3Wrapper headingWrapper\"\u003e\n        \u003ch3\u003eh3ci\u003c/h3\u003e\n        \u003cp\u003etext3ci\u003c/p\u003e\n      \u003c/section\u003e\n    \u003c/section\u003e\n  \u003c/section\u003e\n\u003c/section\u003e\n```\n\n## API\n\n### `rehype().use(section)`\n\nWraps headings and their contents in `\u003csection\u003e` elements.\n\n## Contribute\n\nSee [`contributing.md` in `rehypejs/rehype`][contribute] for ways to get\nstarted.\n\nThis organisation has a [Code of Conduct][coc]. By interacting with this\nrepository, organisation, or community you agree to abide by its terms.\n\n## License\n\n[MIT][license] © [Agent of User][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://img.shields.io/travis/agentofuser/rehype-section.svg\n[build]: https://travis-ci.org/agentofuser/rehype-section\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-section.svg\n[downloads]: https://www.npmjs.com/package/@agentofuser/rehype-section\n[chat-badge]:\n  https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg\n[chat]: https://spectrum.chat/unified/rehype\n[npm]: https://docs.npmjs.com/cli/install\n[license]: license\n[author]: https://agentofuser.com\n[rehype]: https://github.com/rehypejs/rehype\n[contribute]: https://github.com/rehypejs/rehype/blob/master/contributing.md\n[coc]: https://github.com/rehypejs/rehype/blob/master/code-of-conduct.md\n","funding_links":["https://interplanetarygatsby.com/patrons/"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentofuser%2Frehype-section","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagentofuser%2Frehype-section","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentofuser%2Frehype-section/lists"}