Skip to content

Commit 99309ce

Browse files
committed
Add improved docs
1 parent 32515d3 commit 99309ce

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

lib/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99

1010
// To do next major: return `undefined`.
1111
/**
12-
* Rank of a heading: H1 -> 1, H2 -> 2, etc.
12+
* Get the rank (`1` to `6`) of headings (`h1` to `h6`).
1313
*
1414
* @param {Node} node
15+
* Node to check.
1516
* @returns {number | null}
17+
* Rank of the heading or `null` if not a heading.
1618
*/
1719
export function headingRank(node) {
1820
const name =

readme.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[hast][] utility to transform to get the rank (also known as depth or level) of
12-
headings.
11+
[hast][] utility to get the rank (also known as depth or level) of headings.
1312

1413
## Contents
1514

@@ -28,8 +27,8 @@ headings.
2827

2928
## What is this?
3029

31-
This package is a utility that lets you get the rank (`1..6`) of heading
32-
elements (`h1..h6`).
30+
This package is a utility that lets you get the rank (`1`, `6`) of heading
31+
elements (`h1`, `h6`).
3332

3433
## When should I use this?
3534

@@ -42,7 +41,7 @@ To change heading ranks, use
4241
## Install
4342

4443
This package is [ESM only][esm].
45-
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
44+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4645

4746
```sh
4847
npm install hast-util-heading-rank
@@ -74,7 +73,7 @@ headingRank(h('h5', 'Alpha')) //=> 5
7473

7574
## API
7675

77-
This package exports the identifier `headingRank`.
76+
This package exports the identifier [`headingRank`][headingrank].
7877
There is no default export.
7978

8079
### `headingRank(node)`
@@ -83,7 +82,8 @@ Get the rank (`1` to `6`) of headings (`h1` to `h6`).
8382

8483
###### Parameters
8584

86-
* `node` ([`Node`][node]) — node to check
85+
* `node` ([`Node`][node])
86+
— node to check
8787

8888
###### Returns
8989

@@ -98,7 +98,7 @@ It exports no additional types.
9898

9999
Projects maintained by the unified collective are compatible with all maintained
100100
versions of Node.js.
101-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
101+
As of now, that is Node.js 14.14+ and 16.0+.
102102
Our projects sometimes work with older versions, but this is not guaranteed.
103103

104104
## Security
@@ -182,3 +182,5 @@ abide by its terms.
182182
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
183183

184184
[hast-util-shift-heading]: https://github.com/syntax-tree/hast-util-shift-heading
185+
186+
[headingrank]: #headingranknode

0 commit comments

Comments
 (0)