Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agentofuser/rehype-section
Wraps headings and their contents in `<section>` elements.
https://github.com/agentofuser/rehype-section
rehype rehype-plugin typescript typescript-library unist
Last synced: 7 days ago
JSON representation
Wraps headings and their contents in `<section>` elements.
- Host: GitHub
- URL: https://github.com/agentofuser/rehype-section
- Owner: agentofuser
- Created: 2019-05-24T09:48:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T05:46:09.000Z (almost 2 years ago)
- Last Synced: 2024-12-23T10:36:45.318Z (11 days ago)
- Topics: rehype, rehype-plugin, typescript, typescript-library, unist
- Language: TypeScript
- Homepage: https://npm.im/@agentofuser/rehype-section
- Size: 4.33 MB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 46
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# rehype-section
[![Downloads][downloads-badge]][downloads] [![Chat][chat-badge]][chat]
Wraps headings and their contents in `` elements.
## Installation
[npm][]:
```bash
npm install @agentofuser/rehype-section
```## Usage
Say we have the following file, `fragment.html`:
```html
h1
h2a
h3ai
text3ai
h3aj
text3aj
h2b
h3bi
h4bix
text4bix
h2c
h3ci
text3ci
```And our script, `example.js`, looks as follows:
```javascript
var fs = require('fs')
var rehype = require('rehype')
var section = require('rehype-section')rehype()
.data('settings', { fragment: true })
.use(section)
.process(fs.readFileSync('fragment.html'), function(err, file) {
if (err) throw err
console.log(String(file))
})
```Now, running `node example` yields:
```html
h1
h2a
h3ai
text3ai
h3aj
text3aj
h2b
h3bi
h4bix
text4bix
h2c
h3ci
text3ci
```
## API
### `rehype().use(section)`
Wraps headings and their contents in `` elements.
## Contribute
See [`contributing.md` in `rehypejs/rehype`][contribute] for ways to get
started.This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.## License
[MIT][license] © [Agent of User][author]
[build-badge]: https://img.shields.io/travis/agentofuser/rehype-section.svg
[build]: https://travis-ci.org/agentofuser/rehype-section
[downloads-badge]: https://img.shields.io/npm/dm/rehype-section.svg
[downloads]: https://www.npmjs.com/package/@agentofuser/rehype-section
[chat-badge]:
https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/rehype
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://agentofuser.com
[rehype]: https://github.com/rehypejs/rehype
[contribute]: https://github.com/rehypejs/rehype/blob/master/contributing.md
[coc]: https://github.com/rehypejs/rehype/blob/master/code-of-conduct.md