unified

Project: syntax-tree/hast-util-heading-rank

Package: hast-util-heading-rank@2.1.0

  1. Dependents: 5
  2. hast utility to get the rank (or depth, level) of headings
  1. util 144
  2. utility 140
  3. unist 127
  4. html 122
  5. hast 73
  6. hast-util 47
  7. heading 27
  8. depth 5
  9. level 5
  10. rank 2

hast-util-heading-rank

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to get the rank (or depth, level) of headings.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install hast-util-heading-rank

Use

import {h} from 'hastscript'
import {headingRank} from 'hast-util-heading-rank'

headingRank(h('p', 'Alpha')) //=> null
headingRank(h('h5', 'Alpha')) //=> 5

API

This package exports the following identifiers: headingRank. There is no default export.

headingRank(node)

Get the rank (1 to 6) of headings (h1 to h6).

Parameters
Returns

rank (number?) — Rank of the heading, or null if not a heading.

Security

hast-util-heading-rank does not mutate. There are no openings for cross-site scripting (XSS) attacks.

Contribute

See contributing.md in syntax-tree/.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