Skip to content

Commit 146fc37

Browse files
committed
Add improved docs
1 parent 45634b4 commit 146fc37

File tree

1 file changed

+83
-17
lines changed

1 file changed

+83
-17
lines changed

readme.md

+83-17
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-
[*script-supporting*][spec].
11+
[hast][] utility to check if a node is [*script-supporting*][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+
* [`scriptSupporting(node)`](#scriptsupportingnode)
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 script-supporting
31+
according to HTML.
1532

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.
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
1839

19-
[npm][]:
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-script-supporting
2345
```
2446

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

2763
```js
@@ -43,13 +79,33 @@ scriptSupporting({
4379

4480
## API
4581

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

4985
### `scriptSupporting(node)`
5086

5187
Check if the given value is a [*script-supporting*][spec] [*element*][element].
5288

89+
###### Parameters
90+
91+
* `node` ([`Node`][node]) — node to check
92+
93+
###### Returns
94+
95+
Whether the `value` is script-supporting (`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.
108+
53109
## Security
54110

55111
`hast-util-script-supporting` does not change the syntax tree so there are no
@@ -61,21 +117,21 @@ openings for [cross-site scripting (XSS)][xss] attacks.
61117
— check if a node is a (certain) element
62118
* [`hast-util-has-property`](https://github.com/syntax-tree/hast-util-has-property)
63119
— check if a node has a property
64-
* [`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)
65121
— check if a node is “Body OK” link element
66-
* [`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)
67123
— check if a node is a conditional comment
68-
* [`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)
69125
— check if a node is a CSS link element
70-
* [`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)
71127
— check if a node is a CSS style element
72128
* [`hast-util-embedded`](https://github.com/syntax-tree/hast-util-embedded)
73129
— check if a node is an embedded element
74130
* [`hast-util-heading`](https://github.com/syntax-tree/hast-util-heading)
75131
— check if a node is a heading element
76132
* [`hast-util-interactive`](https://github.com/syntax-tree/hast-util-interactive)
77133
— check if a node is interactive
78-
* [`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)
79135
— check if a node is a JavaScript script element
80136
* [`hast-util-labelable`](https://github.com/syntax-tree/hast-util-labelable)
81137
— check whether a node is labelable
@@ -90,8 +146,8 @@ openings for [cross-site scripting (XSS)][xss] attacks.
90146

91147
## Contribute
92148

93-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
94-
started.
149+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
150+
ways to get started.
95151
See [`support.md`][support] for ways to get help.
96152

97153
This project has a [code of conduct][coc].
@@ -132,20 +188,30 @@ abide by its terms.
132188

133189
[npm]: https://docs.npmjs.com/cli/install
134190

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

137199
[author]: https://wooorm.com
138200

139-
[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
140204

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

143-
[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
144208

145209
[spec]: https://html.spec.whatwg.org/#script-supporting-elements
146210

147211
[hast]: https://github.com/syntax-tree/hast
148212

149213
[element]: https://github.com/syntax-tree/hast#element
150214

215+
[node]: https://github.com/syntax-tree/hast#nodes
216+
151217
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting

0 commit comments

Comments
 (0)