Skip to content

Commit 510e068

Browse files
committed
Add improved docs
1 parent e20f068 commit 510e068

File tree

1 file changed

+82
-16
lines changed

1 file changed

+82
-16
lines changed

readme.md

+82-16
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-
[*embedded*][spec].
11+
[hast][] utility to check if a node is [*embedded*][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+
* [`embedded(node)`](#embeddednode)
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 embedded content
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-embedded
2345
```
2446

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

2763
```js
@@ -53,6 +89,26 @@ There is no default export.
5389

5490
Check if `node` is an [*embedded*][spec] [*element*][element].
5591

92+
###### Parameters
93+
94+
* `node` ([`Node`][node]) — node to check
95+
96+
###### Returns
97+
98+
Whether `node` is embedded content (`boolean`).
99+
100+
## Types
101+
102+
This package is fully typed with [TypeScript][].
103+
It exports no additional types.
104+
105+
## Compatibility
106+
107+
Projects maintained by the unified collective are compatible with all maintained
108+
versions of Node.js.
109+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
110+
Our projects sometimes work with older versions, but this is not guaranteed.
111+
56112
## Security
57113

58114
`hast-util-embedded` does not change the syntax tree so there are no openings
@@ -64,19 +120,19 @@ for [cross-site scripting (XSS)][xss] attacks.
64120
— check if a node is a (certain) element
65121
* [`hast-util-has-property`](https://github.com/syntax-tree/hast-util-has-property)
66122
— check if a node has a property
67-
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-body-ok-link)
123+
* [`hast-util-is-body-ok-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-body-ok-link)
68124
— check if a node is “Body OK” link element
69-
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-conditional-comment)
125+
* [`hast-util-is-conditional-comment`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-conditional-comment)
70126
— check if a node is a conditional comment
71-
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-link)
127+
* [`hast-util-is-css-link`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-link)
72128
— check if a node is a CSS link element
73-
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-css-style)
129+
* [`hast-util-is-css-style`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-css-style)
74130
— check if a node is a CSS style element
75131
* [`hast-util-heading`](https://github.com/syntax-tree/hast-util-heading)
76132
— check if a node is a heading element
77133
* [`hast-util-interactive`](https://github.com/syntax-tree/hast-util-interactive)
78134
— check if a node is interactive
79-
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/HEAD/packages/hast-util-is-javascript)
135+
* [`hast-util-is-javascript`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-is-javascript)
80136
— check if a node is a JavaScript script element
81137
* [`hast-util-labelable`](https://github.com/syntax-tree/hast-util-labelable)
82138
— check whether a node is labelable
@@ -93,8 +149,8 @@ for [cross-site scripting (XSS)][xss] attacks.
93149

94150
## Contribute
95151

96-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
97-
started.
152+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
153+
ways to get started.
98154
See [`support.md`][support] for ways to get help.
99155

100156
This project has a [code of conduct][coc].
@@ -135,20 +191,30 @@ abide by its terms.
135191

136192
[npm]: https://docs.npmjs.com/cli/install
137193

194+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
195+
196+
[esmsh]: https://esm.sh
197+
198+
[typescript]: https://www.typescriptlang.org
199+
138200
[license]: license
139201

140202
[author]: https://wooorm.com
141203

142-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
204+
[health]: https://github.com/syntax-tree/.github
205+
206+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
143207

144-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
208+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
145209

146-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
210+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
147211

148212
[spec]: https://html.spec.whatwg.org/#embedded-content-2
149213

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

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

154220
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting

0 commit comments

Comments
 (0)