|
8 | 8 | [![Backers][backers-badge]][collective]
|
9 | 9 | [![Chat][chat-badge]][chat]
|
10 | 10 |
|
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. |
13 | 32 | Paragraphs are considered empty if they do not contain non-whitespace
|
14 | 33 | characters.
|
15 | 34 |
|
16 |
| -## Install |
| 35 | +## When should I use this? |
17 | 36 |
|
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. |
20 | 39 |
|
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][]: |
22 | 47 |
|
23 | 48 | ```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> |
25 | 64 | ```
|
26 | 65 |
|
27 | 66 | ## Use
|
@@ -52,30 +91,45 @@ Yields:
|
52 | 91 |
|
53 | 92 | ## API
|
54 | 93 |
|
55 |
| -This package exports the following identifiers: `squeezeParagraphs`. |
| 94 | +This package exports the identifier `squeezeParagraphs`. |
56 | 95 | There is no default export.
|
57 | 96 |
|
58 | 97 | ### `squeezeParagraphs(tree)`
|
59 | 98 |
|
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. |
62 | 116 |
|
63 | 117 | ## Security
|
64 | 118 |
|
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. |
67 | 121 |
|
68 | 122 | ## Related
|
69 | 123 |
|
70 |
| -* [`remark-squeeze-paragraphs`][squeeze-paragraphs] |
71 |
| - — [**remark**][remark] plugin wrapper |
| 124 | +* [`remark-squeeze-paragraphs`][remark-squeeze-paragraphs] |
| 125 | + — remark plugin |
72 | 126 | * [`mdast-util-compact`](https://github.com/syntax-tree/mdast-util-compact)
|
73 | 127 | — make a tree compact
|
74 | 128 |
|
75 | 129 | ## Contribute
|
76 | 130 |
|
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. |
79 | 133 | See [`support.md`][support] for ways to get help.
|
80 | 134 |
|
81 | 135 | This project has a [code of conduct][coc].
|
@@ -116,22 +170,30 @@ abide by its terms.
|
116 | 170 |
|
117 | 171 | [npm]: https://docs.npmjs.com/cli/install
|
118 | 172 |
|
119 |
| -[license]: license |
| 173 | +[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
120 | 174 |
|
121 |
| -[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md |
| 175 | +[esmsh]: https://esm.sh |
122 | 176 |
|
123 |
| -[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md |
| 177 | +[typescript]: https://www.typescriptlang.org |
124 | 178 |
|
125 |
| -[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md |
| 179 | +[license]: license |
126 | 180 |
|
127 |
| -[tree]: https://github.com/syntax-tree/unist#tree |
| 181 | +[health]: https://github.com/syntax-tree/.github |
128 | 182 |
|
129 |
| -[mdast]: https://github.com/syntax-tree/mdast |
| 183 | +[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md |
130 | 184 |
|
131 |
| -[remark]: https://github.com/remarkjs/remark |
| 185 | +[support]: https://github.com/syntax-tree/.github/blob/main/support.md |
132 | 186 |
|
133 |
| -[squeeze-paragraphs]: https://github.com/remarkjs/remark-squeeze-paragraphs |
| 187 | +[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md |
134 | 188 |
|
135 | 189 | [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
136 | 190 |
|
137 | 191 | [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