{"id":29423727,"url":"https://github.com/syntax-tree/hast-util-heading-rank","last_synced_at":"2025-07-12T07:38:10.132Z","repository":{"id":43405839,"uuid":"244879356","full_name":"syntax-tree/hast-util-heading-rank","owner":"syntax-tree","description":"utility to get the rank (or depth, level) of headings","archived":false,"fork":false,"pushed_at":"2023-08-02T13:17:37.000Z","size":72,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-30T11:12:07.115Z","etag":null,"topics":["depth","hast","hast-util","heading","html","level","rank","syntax-tree","util"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-04T11:08:07.000Z","updated_at":"2025-03-24T01:48:41.000Z","dependencies_parsed_at":"2024-06-18T16:58:45.983Z","dependency_job_id":"f78ce2af-6f90-4e1c-bd27-10cad8f20772","html_url":"https://github.com/syntax-tree/hast-util-heading-rank","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.02083333333333337,"last_synced_commit":"820f0b315aa86eb33b4bdd193b5c5ba8d0548d71"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/hast-util-heading-rank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-heading-rank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-heading-rank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-heading-rank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-heading-rank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/hast-util-heading-rank/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-heading-rank/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264958203,"owners_count":23689012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["depth","hast","hast-util","heading","html","level","rank","syntax-tree","util"],"created_at":"2025-07-12T07:38:00.133Z","updated_at":"2025-07-12T07:38:10.125Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# hast-util-heading-rank\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[hast][] utility to get the rank (also known as depth or level) of headings.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`headingRank(node)`](#headingranknode)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a utility that lets you get the rank (`1`, `6`) of heading\nelements (`h1`, `h6`).\n\n## When should I use this?\n\nThis utility is pretty niche, if you’re here you probably know what you’re\nlooking for!\n\nTo change heading ranks, use\n[`hast-util-shift-heading`][hast-util-shift-heading].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install hast-util-heading-rank\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {headingRank} from 'https://esm.sh/hast-util-heading-rank@3'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {headingRank} from 'https://esm.sh/hast-util-heading-rank@3?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {h} from 'hastscript'\nimport {headingRank} from 'hast-util-heading-rank'\n\nheadingRank(h('p', 'Alpha')) //=\u003e undefined\nheadingRank(h('h5', 'Alpha')) //=\u003e 5\n```\n\n## API\n\nThis package exports the identifier [`headingRank`][api-heading-rank].\nThere is no default export.\n\n### `headingRank(node)`\n\nGet the rank (`1` to `6`) of headings (`h1` to `h6`).\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node to check\n\n###### Returns\n\nRank of the heading (`number`) or `undefined` if not a heading.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`hast-util-heading-rank@^3`, compatible with Node.js 16.\n\n## Security\n\n`hast-util-heading-rank` does not mutate.\nThere are no openings for [cross-site scripting (XSS)][xss] attacks.\n\n## Related\n\n*   [`hast-util-heading`](https://github.com/syntax-tree/hast-util-heading)\n    — check if a node is heading content\n*   [`hast-util-shift-heading`](https://github.com/syntax-tree/hast-util-heading)\n    — change heading rank\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definition --\u003e\n\n[build-badge]: https://github.com/syntax-tree/hast-util-heading-rank/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/hast-util-heading-rank/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-heading-rank.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/hast-util-heading-rank\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-heading-rank.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-heading-rank\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=hast-util-heading-rank\n\n[size]: https://bundlejs.com/?q=hast-util-heading-rank\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[hast]: https://github.com/syntax-tree/hast\n\n[node]: https://github.com/syntax-tree/hast#nodes\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[hast-util-shift-heading]: https://github.com/syntax-tree/hast-util-shift-heading\n\n[api-heading-rank]: #headingranknode\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-heading-rank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fhast-util-heading-rank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-heading-rank/lists"}