|
17 | 17 | * [Install](#install)
|
18 | 18 | * [Use](#use)
|
19 | 19 | * [API](#api)
|
20 |
| - * [`truncate(tree, options?)`](#truncatetree-options) |
| 20 | + * [`truncate(tree[, options])`](#truncatetree-options) |
| 21 | + * [`Options`](#options) |
21 | 22 | * [Types](#types)
|
22 | 23 | * [Compatibility](#compatibility)
|
23 | 24 | * [Security](#security)
|
@@ -47,7 +48,7 @@ document, for use with [`rehype-meta`][rehype-meta].
|
47 | 48 | ## Install
|
48 | 49 |
|
49 | 50 | This package is [ESM only][esm].
|
50 |
| -In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: |
| 51 | +In Node.js (version 14.14+ or 16.0+), install with [npm][]: |
51 | 52 |
|
52 | 53 | ```sh
|
53 | 54 | npm install hast-util-truncate
|
@@ -109,16 +110,29 @@ console.log(truncate(tree, {ellipsis: '…'}));
|
109 | 110 |
|
110 | 111 | ## API
|
111 | 112 |
|
112 |
| -This package exports the identifier `truncate`. |
| 113 | +This package exports the identifier [`truncate`][truncate]. |
113 | 114 | There is no default export.
|
114 | 115 |
|
115 |
| -### `truncate(tree, options?)` |
| 116 | +### `truncate(tree[, options])` |
116 | 117 |
|
117 | 118 | Truncate the tree to a certain number of characters.
|
118 | 119 |
|
119 |
| -##### `options` |
| 120 | +###### Parameters |
120 | 121 |
|
121 |
| -Configuration (optional). |
| 122 | +* `tree` ([`Node`][node]) |
| 123 | + — tree to truncate |
| 124 | +* `options` ([`Options`][options], optional) |
| 125 | + — configuration |
| 126 | + |
| 127 | +###### Returns |
| 128 | + |
| 129 | +Truncated copy of `tree` ([`Node`][node]). |
| 130 | + |
| 131 | +### `Options` |
| 132 | + |
| 133 | +Configuration (TypeScript type). |
| 134 | + |
| 135 | +##### Fields |
122 | 136 |
|
123 | 137 | ###### `options.size`
|
124 | 138 |
|
@@ -149,27 +163,23 @@ Set `maxCharacterStrip: 0` to not find a nice break.
|
149 | 163 | Nodes to exclude from the resulting tree (`Array<Node>`).
|
150 | 164 | These are not counted towards `size`.
|
151 | 165 |
|
152 |
| -###### Returns |
153 |
| - |
154 |
| -Truncated copy of `tree` (`Node`). |
155 |
| - |
156 | 166 | ## Types
|
157 | 167 |
|
158 | 168 | This package is fully typed with [TypeScript][].
|
159 |
| -It exports the additional type `Options`. |
| 169 | +It exports the additional type [`Options`][options]. |
160 | 170 |
|
161 | 171 | ## Compatibility
|
162 | 172 |
|
163 | 173 | Projects maintained by the unified collective are compatible with all maintained
|
164 | 174 | versions of Node.js.
|
165 |
| -As of now, that is Node.js 12.20+, 14.14+, and 16.0+. |
| 175 | +As of now, that is Node.js 14.14+ and 16.0+. |
166 | 176 | Our projects sometimes work with older versions, but this is not guaranteed.
|
167 | 177 |
|
168 | 178 | ## Security
|
169 | 179 |
|
170 | 180 | Use of `hast-util-truncate` should be safe if the tree is already safe and
|
171 | 181 | you’re not using user content in options.
|
172 |
| -When in doubt, use [`hast-util-sanitize`][sanitize]. |
| 182 | +When in doubt, use [`hast-util-sanitize`][hast-util-sanitize]. |
173 | 183 |
|
174 | 184 | ## Related
|
175 | 185 |
|
@@ -242,12 +252,18 @@ abide by its terms.
|
242 | 252 |
|
243 | 253 | [coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
244 | 254 |
|
245 |
| -[sanitize]: https://github.com/syntax-tree/hast-util-sanitize |
246 |
| - |
247 | 255 | [hast]: https://github.com/syntax-tree/hast
|
248 | 256 |
|
| 257 | +[node]: https://github.com/syntax-tree/hast#nodes |
| 258 | + |
| 259 | +[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize |
| 260 | + |
249 | 261 | [hast-util-excerpt]: https://github.com/syntax-tree/hast-util-excerpt
|
250 | 262 |
|
251 | 263 | [rehype-infer-description-meta]: https://github.com/rehypejs/rehype-infer-description-meta
|
252 | 264 |
|
253 | 265 | [rehype-meta]: https://github.com/rehypejs/rehype-meta
|
| 266 | + |
| 267 | +[truncate]: #truncatetree-options |
| 268 | + |
| 269 | +[options]: #options |
0 commit comments