Skip to content

Commit e61a231

Browse files
committed
Add improved docs
1 parent 28aba50 commit e61a231

File tree

1 file changed

+75
-19
lines changed

1 file changed

+75
-19
lines changed

readme.md

Lines changed: 75 additions & 19 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 `node` is a [*transparent*][spec]
12-
[*element*][element].
11+
[hast][] utility to check if a node is [*transparent*][spec] content.
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+
* [`transparent(node)`](#transparentnode)
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 transparent content
31+
according to 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-transparent
2345
```
2446

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

2763
```js
@@ -43,7 +79,7 @@ transparent({
4379

4480
## API
4581

46-
This package exports the following identifiers: `transparent`.
82+
This package exports the identifier `transparent`.
4783
There is no default export.
4884

4985
### `transparent(node)`
@@ -52,11 +88,23 @@ Check if the given value is a [*transparent*][spec] [*element*][element].
5288

5389
###### Parameters
5490

55-
* `node` (`*`) — Value to check, probably [`Element`][element].
91+
* `node` (`*`) — value to check, probably [`Element`][element].
5692

5793
###### Returns
5894

59-
`boolean` — whether `node` passes the test.
95+
Whether `node` passes the test (`boolean`).
96+
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.
60108

61109
## Security
62110

@@ -85,21 +133,21 @@ for [cross-site scripting (XSS)][xss] attacks.
85133
— check if a node is interactive
86134
* [`hast-util-script-supporting`](https://github.com/syntax-tree/hast-util-script-supporting)
87135
— check if a node is a script-supporting element
88-
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-body-ok-link)
136+
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-body-ok-link)
89137
— check if a node is “Body OK” link element
90-
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-conditional-comment)
138+
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-conditional-comment)
91139
— check if a node is a conditional comment
92-
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-link)
140+
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-link)
93141
— check if a node is a CSS link element
94-
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-style)
142+
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-style)
95143
— check if a node is a CSS style element
96-
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-javascript)
144+
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-javascript)
97145
— check if a node is a JavaScript script element
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/#transparent-content-models
154210

0 commit comments

Comments
 (0)