8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** hast** ] [ hast ] utility to get the rank (or depth, level) of headings.
11
+ [ hast] [ ] utility to transform to get the rank (also known as depth or level) of
12
+ headings.
12
13
13
- ## Install
14
+ ## Contents
15
+
16
+ * [ What is this?] ( #what-is-this )
17
+ * [ When should I use this?] ( #when-should-i-use-this )
18
+ * [ Install] ( #install )
19
+ * [ Use] ( #use )
20
+ * [ API] ( #api )
21
+ * [ ` headingRank(node) ` ] ( #headingranknode )
22
+ * [ Types] ( #types )
23
+ * [ Compatibility] ( #compatibility )
24
+ * [ Security] ( #security )
25
+ * [ Related] ( #related )
26
+ * [ Contribute] ( #contribute )
27
+ * [ License] ( #license )
28
+
29
+ ## What is this?
30
+
31
+ This package is a utility that lets you get the rank (` 1..6 ` ) of heading
32
+ elements (` h1..h6 ` ).
33
+
34
+ ## When should I use this?
35
+
36
+ This utility is pretty niche, if you’re here you probably know what you’re
37
+ looking for!
14
38
15
- This package is [ ESM only ] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
16
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d .
39
+ To change heading ranks, use
40
+ [ ` hast-util-shift-heading ` ] [ hast-util-shift-heading ] .
17
41
18
- [ npm] [ ] :
42
+ ## Install
43
+
44
+ This package is [ ESM only] [ esm ] .
45
+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
19
46
20
47
``` sh
21
48
npm install hast-util-heading-rank
22
49
```
23
50
51
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
52
+
53
+ ``` js
54
+ import {headingRank } from ' https://esm.sh/hast-util-heading-rank@2'
55
+ ```
56
+
57
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
58
+
59
+ ``` html
60
+ <script type =" module" >
61
+ import {headingRank } from ' https://esm.sh/hast-util-heading-rank@2?bundle'
62
+ </script >
63
+ ```
64
+
24
65
## Use
25
66
26
67
``` js
@@ -33,7 +74,7 @@ headingRank(h('h5', 'Alpha')) //=> 5
33
74
34
75
## API
35
76
36
- This package exports the following identifiers: ` headingRank ` .
77
+ This package exports the identifier ` headingRank ` .
37
78
There is no default export.
38
79
39
80
### ` headingRank(node) `
@@ -42,11 +83,23 @@ Get the rank (`1` to `6`) of headings (`h1` to `h6`).
42
83
43
84
###### Parameters
44
85
45
- * ` node ` ([ ` Node ` ] [ node ] ) — Node to check
86
+ * ` node ` ([ ` Node ` ] [ node ] ) — node to check
46
87
47
88
###### Returns
48
89
49
- ` rank ` (` number? ` ) — Rank of the heading, or ` null ` if not a heading.
90
+ Rank of the heading or ` null ` if not a heading (` number? ` ).
91
+
92
+ ## Types
93
+
94
+ This package is fully typed with [ TypeScript] [ ] .
95
+ It exports no additional types.
96
+
97
+ ## Compatibility
98
+
99
+ Projects maintained by the unified collective are compatible with all maintained
100
+ versions of Node.js.
101
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
102
+ Our projects sometimes work with older versions, but this is not guaranteed.
50
103
51
104
## Security
52
105
@@ -56,14 +109,14 @@ There are no openings for [cross-site scripting (XSS)][xss] attacks.
56
109
## Related
57
110
58
111
* [ ` hast-util-heading ` ] ( https://github.com/syntax-tree/hast-util-heading )
59
- — check if a node is a heading element
112
+ — check if a node is heading content
60
113
* [ ` hast-util-shift-heading ` ] ( https://github.com/syntax-tree/hast-util-heading )
61
- — utility to change heading rank
114
+ — change heading rank
62
115
63
116
## Contribute
64
117
65
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
66
- started.
118
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
119
+ ways to get started.
67
120
See [ ` support.md ` ] [ support ] for ways to get help.
68
121
69
122
This project has a [ code of conduct] [ coc ] .
@@ -104,18 +157,28 @@ abide by its terms.
104
157
105
158
[ npm ] : https://docs.npmjs.com/cli/install
106
159
160
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
161
+
162
+ [ esmsh ] : https://esm.sh
163
+
164
+ [ typescript ] : https://www.typescriptlang.org
165
+
107
166
[ license ] : license
108
167
109
168
[ author ] : https://wooorm.com
110
169
111
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
170
+ [ health ] : https://github.com/syntax-tree/.github
171
+
172
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
112
173
113
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
174
+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
114
175
115
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD /code-of-conduct.md
176
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main /code-of-conduct.md
116
177
117
178
[ hast ] : https://github.com/syntax-tree/hast
118
179
119
180
[ node ] : https://github.com/syntax-tree/hast#nodes
120
181
121
182
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
183
+
184
+ [ hast-util-shift-heading ] : https://github.com/syntax-tree/hast-util-shift-heading
0 commit comments