Skip to content

Commit cbfbbc9

Browse files
committed
Add improved docs
1 parent 1d191ee commit cbfbbc9

File tree

2 files changed

+88
-24
lines changed

2 files changed

+88
-24
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import {remove} from 'unist-util-remove'
77

88
/**
9+
* Remove empty paragraphs in `tree`.
10+
*
911
* @template {Node} Tree
1012
* @param {Tree} tree
1113
* @returns {Tree extends Paragraph ? Tree | null : Tree}

readme.md

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,59 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**mdast**][mdast] utility to remove empty paragraphs from a tree.
12-
11+
[mdast][] utility to remove empty paragraphs.
12+
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+
* [`squeezeParagraphs(tree)`](#squeezeparagraphstree)
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 utility that removes empty paragraphs, left over from other
31+
operations, from the tree.
1332
Paragraphs are considered empty if they do not contain non-whitespace
1433
characters.
1534

16-
## Install
35+
## When should I use this?
1736

18-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
19-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
37+
Probably never!
38+
You should try to clean your trees yourself.
2039

21-
[npm][]:
40+
A plugin, [`remark-squeeze-paragraphs`][remark-squeeze-paragraphs], exists that
41+
does the same but for [remark][].
42+
43+
## Install
44+
45+
This package is [ESM only][esm].
46+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
2247

2348
```sh
24-
npm install mdast-squeeze-paragraphs
49+
npm install mdast-util-squeeze-paragraphs
50+
```
51+
52+
In Deno with [`esm.sh`][esmsh]:
53+
54+
```js
55+
import {squeezeParagraphs} from 'https://esm.sh/mdast-util-squeeze-paragraphs@5'
56+
```
57+
58+
In browsers with [`esm.sh`][esmsh]:
59+
60+
```html
61+
<script type="module">
62+
import {squeezeParagraphs} from 'https://esm.sh/mdast-util-squeeze-paragraphs@5?bundle'
63+
</script>
2564
```
2665

2766
## Use
@@ -52,30 +91,45 @@ Yields:
5291

5392
## API
5493

55-
This package exports the following identifiers: `squeezeParagraphs`.
94+
This package exports the identifier `squeezeParagraphs`.
5695
There is no default export.
5796

5897
### `squeezeParagraphs(tree)`
5998

60-
Modifies [tree][] in-place.
61-
Returns `tree`.
99+
Remove empty paragraphs in `tree` ([`Node`][node]).
100+
101+
###### Returns
102+
103+
The given `tree` ([`Node`][node]).
104+
105+
## Types
106+
107+
This package is fully typed with [TypeScript][].
108+
There are no additional types exported.
109+
110+
## Compatibility
111+
112+
Projects maintained by the unified collective are compatible with all maintained
113+
versions of Node.js.
114+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
115+
Our projects sometimes work with older versions, but this is not guaranteed.
62116

63117
## Security
64118

65-
Use of `mdast-squeeze-paragraphs` does not involve [**hast**][hast] or user
66-
content so there are no openings for [cross-site scripting (XSS)][xss] attacks.
119+
Use of `mdast-squeeze-paragraphs` does not involve **[hast][]** or user content
120+
so there are no openings for [cross-site scripting (XSS)][xss] attacks.
67121

68122
## Related
69123

70-
* [`remark-squeeze-paragraphs`][squeeze-paragraphs]
71-
[**remark**][remark] plugin wrapper
124+
* [`remark-squeeze-paragraphs`][remark-squeeze-paragraphs]
125+
— remark plugin
72126
* [`mdast-util-compact`](https://github.com/syntax-tree/mdast-util-compact)
73127
— make a tree compact
74128

75129
## Contribute
76130

77-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
78-
started.
131+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
132+
ways to get started.
79133
See [`support.md`][support] for ways to get help.
80134

81135
This project has a [code of conduct][coc].
@@ -116,22 +170,30 @@ abide by its terms.
116170

117171
[npm]: https://docs.npmjs.com/cli/install
118172

119-
[license]: license
173+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
120174

121-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
175+
[esmsh]: https://esm.sh
122176

123-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
177+
[typescript]: https://www.typescriptlang.org
124178

125-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
179+
[license]: license
126180

127-
[tree]: https://github.com/syntax-tree/unist#tree
181+
[health]: https://github.com/syntax-tree/.github
128182

129-
[mdast]: https://github.com/syntax-tree/mdast
183+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
130184

131-
[remark]: https://github.com/remarkjs/remark
185+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
132186

133-
[squeeze-paragraphs]: https://github.com/remarkjs/remark-squeeze-paragraphs
187+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
134188

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

137191
[hast]: https://github.com/syntax-tree/hast
192+
193+
[mdast]: https://github.com/syntax-tree/mdast
194+
195+
[node]: https://github.com/syntax-tree/mdast#node
196+
197+
[remark]: https://github.com/remarkjs/remark
198+
199+
[remark-squeeze-paragraphs]: https://github.com/remarkjs/remark-squeeze-paragraphs

0 commit comments

Comments
 (0)