@hbsnow/rehype-sectionize
v1.0.7
Published
rehype plugin that wraps section based on heading
Downloads
13,656
Readme
rehype-sectionize
Motivation
There is already rehype-section in the library for sectioning. But it could not change the class of section. In addition, sections could not have the slug of heading in the data attribute. I was referred rehype-section. Thanks.
Install
npm i -D @hbsnow/rehype-sectionize
Sample
Input
<h1 id="h1-id">h1</h1>
<h2 id="h2-id">h2</h2>
<h3 id="h3-id">h3</h3>
Output
<section class="heading" data-heading-rank="1" aria-labelledby="h1-id">
<h1 id="h1-id">h1</h1>
<section class="heading" data-heading-rank="2" aria-labelledby="h2-id">
<h2 id="h2-id">h2</h2>
<section class="heading" data-heading-rank="3" aria-labelledby="h3-id">
<h3 id="h3-id">h3</h3>
</section>
</section>
</section>
Options
| option | type | default | description |
| ------------------- | ----------------------- | ----------------- | ------------------------------ |
| properties
| hastscript.Properties
| {}
| Attributes assigned to section |
| enableRootSection
| boolean
| false
| Section to wrap all |
| rankPropertyName
| string
| dataHeadingRank
| Name of rank data attribute |
| idPropertyName
| string
| ariaLabelledby
| Name of id data attribute |