Skip to content

Commit 3c765ef

Browse files
committed
Add improved docs
1 parent 700b295 commit 3c765ef

File tree

1 file changed

+73
-17
lines changed

1 file changed

+73
-17
lines changed

readme.md

Lines changed: 73 additions & 17 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 a `node` is [*inter-element
12-
whitespace*][spec].
11+
[hast][] utility to check if a node is [*inter-element whitespace*][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+
* [`whitespace(node|value)`](#whitespacenodevalue)
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 whitespace 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-whitespace
2345
```
2446

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

2763
```js
@@ -46,7 +82,7 @@ whitespace({
4682

4783
## API
4884

49-
This package exports the following identifiers: `whitespace`.
85+
This package exports the identifier `whitespace`.
5086
There is no default export.
5187

5288
### `whitespace(node|value)`
@@ -60,11 +96,23 @@ Check if the given value is [*inter-element whitespace*][spec].
6096

6197
###### Returns
6298

63-
`boolean`Whether the `value` is inter-element white-space: consisting of zero
99+
Whether the `value` is inter-element whitespace (`boolean`): consisting of zero
64100
or more of space, tab (`\t`), line feed (`\n`), carriage return (`\r`), or form
65101
feed (`\f`).
66102
If `node` is passed it must be a [*text*][text] node.
67103

104+
## Types
105+
106+
This package is fully typed with [TypeScript][].
107+
It exports no additional types.
108+
109+
## Compatibility
110+
111+
Projects maintained by the unified collective are compatible with all maintained
112+
versions of Node.js.
113+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
114+
Our projects sometimes work with older versions, but this is not guaranteed.
115+
68116
## Security
69117

70118
`hast-util-whitespace` does not change the syntax tree so there are no openings
@@ -92,21 +140,21 @@ for [cross-site scripting (XSS)][xss] attacks.
92140
— check if a node is interactive
93141
* [`hast-util-script-supporting`](https://github.com/syntax-tree/hast-util-script-supporting)
94142
— check if a node is a script-supporting element
95-
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-body-ok-link)
143+
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-body-ok-link)
96144
— check if a node is “Body OK” link element
97145
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-conditional-comment)
98146
— check if a node is a conditional comment
99-
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-link)
147+
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-link)
100148
— check if a node is a CSS link element
101-
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-style)
149+
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-style)
102150
— check if a node is a CSS style element
103-
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-javascript)
151+
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-javascript)
104152
— check if a node is a JavaScript script element
105153

106154
## Contribute
107155

108-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
109-
started.
156+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
157+
ways to get started.
110158
See [`support.md`][support] for ways to get help.
111159

112160
This project has a [code of conduct][coc].
@@ -147,15 +195,23 @@ abide by its terms.
147195

148196
[npm]: https://docs.npmjs.com/cli/install
149197

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

152206
[author]: https://wooorm.com
153207

154-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
208+
[health]: https://github.com/syntax-tree/.github
209+
210+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
155211

156-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
212+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
157213

158-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
214+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
159215

160216
[hast]: https://github.com/syntax-tree/hast
161217

0 commit comments

Comments
 (0)