Skip to content

Commit 31d182e

Browse files
committed
Add improved docs
1 parent 10de093 commit 31d182e

File tree

1 file changed

+85
-29
lines changed

1 file changed

+85
-29
lines changed

readme.md

Lines changed: 85 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,101 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
Check if an [mdast][] [node][] is [phrasing content][phrasing].
11+
[mdast][] utility to check if a node is phrasing content.
1212

13-
## 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+
* [`phrasing(node)`](#phrasingnode)
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 tiny utility to check that a given [node][] is [phrasing
31+
content][phrasing].
1432

15-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
16-
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 typically useful if you’re making other utilities.
36+
It uses [`unist-util-is`][unist-util-is], which you can use for your own checks.
37+
38+
A different utility, [`hast-util-phrasing`][hast-util-phrasing], does the same
39+
but on [hast][].
40+
41+
## Install
1742

18-
[npm][]:
43+
This package is [ESM only][esm].
44+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
1945

2046
```sh
2147
npm install mdast-util-phrasing
2248
```
2349

50+
In Deno with [`esm.sh`][esmsh]:
51+
52+
```js
53+
import {phrasing} from 'https://esm.sh/mdast-util-phrasing@3'
54+
```
55+
56+
In browsers with [`esm.sh`][esmsh]:
57+
58+
```html
59+
<script type="module">
60+
import {phrasing} from 'https://esm.sh/mdast-util-phrasing@3?bundle'
61+
</script>
62+
```
63+
2464
## Use
2565

2666
```js
2767
import {phrasing} from 'mdast-util-phrasing'
2868

29-
phrasing({
30-
type: 'paragraph',
31-
children: [{type: 'text', value: 'Alpha'}]
32-
}) // => false
69+
phrasing({type: 'paragraph', children: [{type: 'text', value: 'Alpha'}]})
70+
// => false
3371

34-
phrasing({
35-
type: 'strong',
36-
children: [{type: 'text', value: 'Delta'}]
37-
}) // => true
72+
phrasing({type: 'strong', children: [{type: 'text', value: 'Delta'}]})
73+
// => true
3874
```
3975

4076
## API
4177

42-
This package exports the following identifiers: `phrasing`.
78+
This package exports the identifier `phrasing`.
4379
There is no default export.
4480

4581
### `phrasing(node)`
4682

47-
Check if the given value is a phrasing element.
83+
Check if the given value (`unknown`) is phrasing content.
4884

49-
###### Parameters
85+
###### Returns
5086

51-
`node` (`*`) — Value to check, typically a [node][].
87+
Whether `node` is [phrasing content][phrasing] (`boolean`).
5288

53-
###### Returns
89+
## Types
90+
91+
This package is fully typed with [TypeScript][].
92+
It does not export extra types.
93+
94+
## Compatibility
5495

55-
`boolean` — whether `node` is [phrasing content][phrasing].
96+
Projects maintained by the unified collective are compatible with all maintained
97+
versions of Node.js.
98+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
99+
Our projects sometimes work with older versions, but this is not guaranteed.
56100

57101
## Security
58102

59-
Use of `mdast-util-phrasing` does not involve [**hast**][hast], user content,
60-
or change the tree, so there are no openings for
61-
[cross-site scripting (XSS)][xss] attacks.
103+
Use of `mdast-util-phrasing` does not involve **[hast][]**, user content, or
104+
change the tree, so there are no openings for [cross-site scripting (XSS)][xss]
105+
attacks.
62106

63107
## Related
64108

@@ -69,8 +113,8 @@ or change the tree, so there are no openings for
69113

70114
## Contribute
71115

72-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
73-
started.
116+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
117+
ways to get started.
74118
See [`support.md`][support] for ways to get help.
75119

76120
This project has a [code of conduct][coc].
@@ -111,22 +155,34 @@ abide by its terms.
111155

112156
[npm]: https://docs.npmjs.com/cli/install
113157

158+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
159+
160+
[esmsh]: https://esm.sh
161+
162+
[typescript]: https://www.typescriptlang.org
163+
114164
[license]: license
115165

116166
[author]: https://draft.li
117167

118-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
168+
[health]: https://github.com/syntax-tree/.github
119169

120-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
170+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
121171

122-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
172+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
173+
174+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
175+
176+
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
177+
178+
[hast]: https://github.com/syntax-tree/hast
123179

124180
[mdast]: https://github.com/syntax-tree/mdast
125181

126182
[node]: https://github.com/syntax-tree/mdast#nodes
127183

128184
[phrasing]: https://github.com/syntax-tree/mdast#phrasingcontent
129185

130-
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
186+
[unist-util-is]: https://github.com/syntax-tree/unist-util-is
131187

132-
[hast]: https://github.com/syntax-tree/hast
188+
[hast-util-phrasing]: https://github.com/syntax-tree/hast-util-phrasing

0 commit comments

Comments
 (0)