Napoleonic Political Magnificence
    Have ideas to improve npm?Join in the discussion! »

    hast-util-heading-rank
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    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

    var h = require('hastscript')
    var rank = require('hast-util-heading-rank')
    
    rank(h('p', 'Alpha')) //=> null
    rank(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
    • node (Node) — Node to check
    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.

    Related

    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

    Install

    npm i hast-util-heading-rank

    DownloadsWeekly Downloads

    8,907

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    7.24 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar