Skip to content

Commit 56f5b6b

Browse files
committed
Add improved docs
1 parent f397753 commit 56f5b6b

File tree

1 file changed

+74
-18
lines changed

1 file changed

+74
-18
lines changed

readme.md

Lines changed: 74 additions & 18 deletions
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-
[*labelable*][spec].
11+
[hast][] utility to check if a node is [*labelable*][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+
* [`labelable(node)`](#labelablenode)
21+
* [Types](#types)
22+
* [Compatibility](#compatibility)
23+
* [Security](#security)
24+
* [Related](#related)
25+
* [Contribute](#contribute)
26+
* [License](#license)
27+
28+
## What is this?
1529

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.
30+
This package is a small utility that checks if a node is labelable according to
31+
HTML.
1832

19-
[npm][]:
33+
## When should I use this?
34+
35+
This utility is super niche, if you’re here you probably know what you’re
36+
looking for!
37+
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-labelable
2345
```
2446

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

2763
```js
@@ -40,7 +76,7 @@ labelable({
4076

4177
## API
4278

43-
This package exports the following identifiers: `labelable`.
79+
This package exports the identifier `labelable`.
4480
There is no default export.
4581

4682
### `labelable(node)`
@@ -53,11 +89,23 @@ Check if the given value is a [*labelable*][spec] [*element*][element].
5389

5490
###### Returns
5591

56-
`boolean`Whether `node` is a labelable element.
92+
Whether `node` is a labelable element (`boolean`).
5793
Labelable nodes have a `tagName` set to `button`, `keygen`,
5894
`meter`, `output`, `progress`, `select`, `textarea`, and `input`
5995
(excluding `[type=hidden]`).
6096

97+
## Types
98+
99+
This package is fully typed with [TypeScript][].
100+
It exports no additional types.
101+
102+
## Compatibility
103+
104+
Projects maintained by the unified collective are compatible with all maintained
105+
versions of Node.js.
106+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
107+
Our projects sometimes work with older versions, but this is not guaranteed.
108+
61109
## Security
62110

63111
`hast-util-labelable` does not change the syntax tree so there are no openings
@@ -69,21 +117,21 @@ for [cross-site scripting (XSS)][xss] attacks.
69117
— check if a node is a (certain) element
70118
* [`hast-util-has-property`](https://github.com/syntax-tree/hast-util-has-property)
71119
— check if a node has a property
72-
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-body-ok-link)
120+
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-body-ok-link)
73121
— check if a node is “Body OK” link element
74-
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-conditional-comment)
122+
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-conditional-comment)
75123
— check if a node is a conditional comment
76-
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-link)
124+
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-link)
77125
— check if a node is a CSS link element
78-
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-style)
126+
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-style)
79127
— check if a node is a CSS style element
80128
* [`hast-util-embedded`](https://github.com/syntax-tree/hast-util-embedded)
81129
— check if a node is an embedded element
82130
* [`hast-util-heading`](https://github.com/syntax-tree/hast-util-heading)
83131
— check if a node is a heading element
84132
* [`hast-util-interactive`](https://github.com/syntax-tree/hast-util-interactive)
85133
— check if a node is interactive
86-
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-javascript)
134+
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-javascript)
87135
— check if a node is a JavaScript script element
88136
* [`hast-util-phrasing`](https://github.com/syntax-tree/hast-util-phrasing)
89137
— check if a node is phrasing content
@@ -98,8 +146,8 @@ for [cross-site scripting (XSS)][xss] attacks.
98146

99147
## Contribute
100148

101-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
102-
started.
149+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
150+
ways to get started.
103151
See [`support.md`][support] for ways to get help.
104152

105153
This project has a [code of conduct][coc].
@@ -140,15 +188,23 @@ abide by its terms.
140188

141189
[npm]: https://docs.npmjs.com/cli/install
142190

191+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
192+
193+
[esmsh]: https://esm.sh
194+
195+
[typescript]: https://www.typescriptlang.org
196+
143197
[license]: license
144198

145199
[author]: https://wooorm.com
146200

147-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
201+
[health]: https://github.com/syntax-tree/.github
202+
203+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
148204

149-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
205+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
150206

151-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
207+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
152208

153209
[spec]: https://html.spec.whatwg.org/#category-label
154210

0 commit comments

Comments
 (0)