Package Exports
- @hbsnow/rehype-sectionize
- @hbsnow/rehype-sectionize/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hbsnow/rehype-sectionize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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 |