unified

Project: rehypejs/rehype-shift-heading

Package: rehype-shift-heading@1.0.0

  1. Dependents: 0
  2. rehype plugin to change the rank (depth, level) of headings
  1. unified 174
  2. plugin 137
  3. html 121
  4. rehype 85
  5. hast 72
  6. rehype-plugin 60
  7. heading 26

rehype-shift-heading

Build Coverage Downloads Size Sponsors Backers Chat

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 imported instead of required.

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.

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.

License

MIT © Titus Wormer