README
rehype-shift-heading
rehype plugin to change the rank (depth, level) of headings.
Contents
Install
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install rehype-shift-heading
Use
Say example.js
looks as follows:
import {rehype} from 'rehype'
import rehypeShiftHeading from 'rehype-shift-heading'
rehype()
.data('settings', {fragment: true})
.use(rehypeShiftHeading, {shift: 1})
.process('<h1>Alpha!</h1>')
.then((file) => {
console.log(String(file))
})
Now, running node example
yields:
<h2>Alpha!</h2>
API
This package exports no identifiers.
The default export is rehypeShiftHeading
.
unified().use(rehypeShiftHeading, options)
rehype plugin to change the rank (depth, level) of headings.
Does not shift past h1
and h6
.
options.shift
Number to shift headings (number
, required).
Can be negative to decrease heading levels.
Security
Use of rehype-shift-heading
is safe.
Related
rehype-slug
— Addid
attributes to headingsrehype-autolink-headings
— Add links to headings in HTML
Contribute
See contributing.md
in rehypejs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.