Skip to content

Commit 2beeac4

Browse files
committed
Add improved docs
1 parent 34c9a82 commit 2beeac4

File tree

1 file changed

+88
-22
lines changed

1 file changed

+88
-22
lines changed

readme.md

+88-22
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,56 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**hast**][hast] utility to check if an [*element*][element] is
12-
[*sectioning*][spec].
11+
[hast][] utility to check if a node is [*sectioning*][spec].
1312

14-
## Install
13+
## Contents
14+
15+
* [What is this?](#what-is-this)
16+
* [When should I use this?](#when-should-i-use-this)
17+
* [Install](#install)
18+
* [Use](#use)
19+
* [API](#api)
20+
* [`sectioning(node)`](#sectioningnode)
21+
* [Types](#types)
22+
* [Compatibility](#compatibility)
23+
* [Security](#security)
24+
* [Related](#related)
25+
* [Contribute](#contribute)
26+
* [License](#license)
27+
28+
## What is this?
29+
30+
This package is a small utility that checks if a node is sectioning content
31+
according to HTML.
32+
33+
## When should I use this?
1534

16-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
17-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
35+
This utility is super niche, if you’re here you probably know what you’re
36+
looking for!
1837

19-
[npm][]:
38+
## Install
39+
40+
This package is [ESM only][esm].
41+
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
2042

2143
```sh
2244
npm install hast-util-sectioning
2345
```
2446

47+
In Deno with [`esm.sh`][esmsh]:
48+
49+
```js
50+
import {sectioning} from 'https://esm.sh/hast-util-sectioning@2'
51+
```
52+
53+
In browsers with [`esm.sh`][esmsh]:
54+
55+
```html
56+
<script type="module">
57+
import {sectioning} from 'https://esm.sh/hast-util-sectioning@2?bundle'
58+
</script>
59+
```
60+
2561
## Use
2662

2763
```js
@@ -49,34 +85,59 @@ sectioning({
4985

5086
## API
5187

52-
This package exports the following identifiers: `sectioning`.
88+
This package exports the identifier `sectioning`.
5389
There is no default export.
5490

5591
### `sectioning(node)`
5692

5793
Check if the given value is a [*sectioning*][spec] [*element*][element].
5894

95+
###### Parameters
96+
97+
* `node` ([`Node`][node]) — node to check
98+
99+
###### Returns
100+
101+
Whether `node` is sectioning content (`boolean`).
102+
103+
## Types
104+
105+
This package is fully typed with [TypeScript][].
106+
It exports no additional types.
107+
108+
## Compatibility
109+
110+
Projects maintained by the unified collective are compatible with all maintained
111+
versions of Node.js.
112+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
113+
Our projects sometimes work with older versions, but this is not guaranteed.
114+
115+
## Security
116+
117+
`hast-util-sectioning` does not change the syntax tree so there are no openings
118+
for [cross-site scripting (XSS)][xss] attacks.
119+
59120
## Related
60121

61122
* [`hast-util-is-element`](https://github.com/syntax-tree/hast-util-is-element)
62123
— check if a node is a (certain) element
63124
* [`hast-util-has-property`](https://github.com/syntax-tree/hast-util-has-property)
64125
— check if a node has a property
65-
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-body-ok-link)
126+
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-body-ok-link)
66127
— check if a node is “Body OK” link element
67-
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-conditional-comment)
128+
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-conditional-comment)
68129
— check if a node is a conditional comment
69-
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-link)
130+
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-link)
70131
— check if a node is a CSS link element
71-
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-style)
132+
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-style)
72133
— check if a node is a CSS style element
73134
* [`hast-util-embedded`](https://github.com/syntax-tree/hast-util-embedded)
74135
— check if a node is an embedded element
75136
* [`hast-util-heading`](https://github.com/syntax-tree/hast-util-heading)
76137
— check if a node is a heading element
77138
* [`hast-util-interactive`](https://github.com/syntax-tree/hast-util-interactive)
78139
— check if a node is interactive
79-
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-javascript)
140+
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-javascript)
80141
— check if a node is a JavaScript script element
81142
* [`hast-util-labelable`](https://github.com/syntax-tree/hast-util-labelable)
82143
— check whether a node is labelable
@@ -91,19 +152,14 @@ Check if the given value is a [*sectioning*][spec] [*element*][element].
91152

92153
## Contribute
93154

94-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
95-
started.
155+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
156+
ways to get started.
96157
See [`support.md`][support] for ways to get help.
97158

98159
This project has a [code of conduct][coc].
99160
By interacting with this repository, organization, or community you agree to
100161
abide by its terms.
101162

102-
## Security
103-
104-
`hast-util-sectioning` does not change the syntax tree so there are no openings
105-
for [cross-site scripting (XSS)][xss] attacks.
106-
107163
## License
108164

109165
[MIT][license] © [Titus Wormer][author]
@@ -138,18 +194,28 @@ for [cross-site scripting (XSS)][xss] attacks.
138194

139195
[npm]: https://docs.npmjs.com/cli/install
140196

197+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
198+
199+
[esmsh]: https://esm.sh
200+
201+
[typescript]: https://www.typescriptlang.org
202+
141203
[license]: license
142204

143205
[author]: https://wooorm.com
144206

145-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
207+
[health]: https://github.com/syntax-tree/.github
146208

147-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
209+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
148210

149-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
211+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
212+
213+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
150214

151215
[hast]: https://github.com/syntax-tree/hast
152216

217+
[node]: https://github.com/syntax-tree/hast#nodes
218+
153219
[element]: https://github.com/syntax-tree/hast#element
154220

155221
[spec]: https://html.spec.whatwg.org/#sectioning-content

0 commit comments

Comments
 (0)