|
12 | 12 |
|
13 | 13 | ## Contents |
14 | 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 | | - * [`toText(tree[, options])`](#totexttree-options) |
21 | | - * [`Options`](#options) |
22 | | - * [`Whitespace`](#whitespace) |
23 | | -* [Types](#types) |
24 | | -* [Compatibility](#compatibility) |
25 | | -* [Security](#security) |
26 | | -* [Related](#related) |
27 | | -* [Contribute](#contribute) |
28 | | -* [License](#license) |
| 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 | + * [`toText(tree[, options])`](#totexttree-options) |
| 21 | + * [`Options`](#options) |
| 22 | + * [`Whitespace`](#whitespace) |
| 23 | +* [Types](#types) |
| 24 | +* [Compatibility](#compatibility) |
| 25 | +* [Security](#security) |
| 26 | +* [Related](#related) |
| 27 | +* [Contribute](#contribute) |
| 28 | +* [License](#license) |
29 | 29 |
|
30 | 30 | ## What is this? |
31 | 31 |
|
@@ -111,46 +111,46 @@ Get the plain-text value of a node. |
111 | 111 |
|
112 | 112 | ###### Parameters |
113 | 113 |
|
114 | | -* `tree` ([`Node`][node]) |
115 | | - — tree to turn into text |
116 | | -* `options` ([`Options`][api-options], optional) |
117 | | - — configuration |
| 114 | +* `tree` ([`Node`][node]) |
| 115 | + — tree to turn into text |
| 116 | +* `options` ([`Options`][api-options], optional) |
| 117 | + — configuration |
118 | 118 |
|
119 | 119 | ###### Returns |
120 | 120 |
|
121 | 121 | Serialized `tree` (`string`). |
122 | 122 |
|
123 | 123 | ###### Algorithm |
124 | 124 |
|
125 | | -* if `tree` is a [comment][], returns its `value` |
126 | | -* if `tree` is a [text][], applies normal whitespace collapsing to its |
127 | | - `value`, as defined by the [CSS Text][css] spec |
128 | | -* if `tree` is a [root][] or [element][], applies an algorithm similar to the |
129 | | - `innerText` getter as defined by [HTML][] |
| 125 | +* if `tree` is a [comment][], returns its `value` |
| 126 | +* if `tree` is a [text][], applies normal whitespace collapsing to its |
| 127 | + `value`, as defined by the [CSS Text][css] spec |
| 128 | +* if `tree` is a [root][] or [element][], applies an algorithm similar to the |
| 129 | + `innerText` getter as defined by [HTML][] |
130 | 130 |
|
131 | 131 | ###### Notes |
132 | 132 |
|
133 | 133 | > 👉 **Note**: the algorithm acts as if `tree` is being rendered, and as if |
134 | 134 | > we’re a CSS-supporting user agent, with scripting enabled. |
135 | 135 |
|
136 | | -* if `tree` is an element that is not displayed (such as a `head`), we’ll |
137 | | - still use the `innerText` algorithm instead of switching to `textContent` |
138 | | -* if descendants of `tree` are elements that are not displayed, they are |
139 | | - ignored |
140 | | -* CSS is not considered, except for the default user agent style sheet |
141 | | -* a line feed is collapsed instead of ignored in cases where Fullwidth, Wide, |
142 | | - or Halfwidth East Asian Width characters are used, the same goes for a case |
143 | | - with Chinese, Japanese, or Yi writing systems |
144 | | -* replaced elements (such as `audio`) are treated like non-replaced elements |
| 136 | +* if `tree` is an element that is not displayed (such as a `head`), we’ll |
| 137 | + still use the `innerText` algorithm instead of switching to `textContent` |
| 138 | +* if descendants of `tree` are elements that are not displayed, they are |
| 139 | + ignored |
| 140 | +* CSS is not considered, except for the default user agent style sheet |
| 141 | +* a line feed is collapsed instead of ignored in cases where Fullwidth, Wide, |
| 142 | + or Halfwidth East Asian Width characters are used, the same goes for a case |
| 143 | + with Chinese, Japanese, or Yi writing systems |
| 144 | +* replaced elements (such as `audio`) are treated like non-replaced elements |
145 | 145 |
|
146 | 146 | ### `Options` |
147 | 147 |
|
148 | 148 | Configuration (TypeScript type). |
149 | 149 |
|
150 | 150 | ##### Fields |
151 | 151 |
|
152 | | -* `whitespace` ([`Whitespace`][api-whitespace], default: `'normal'`) |
153 | | - — default whitespace setting to use |
| 152 | +* `whitespace` ([`Whitespace`][api-whitespace], default: `'normal'`) |
| 153 | + — default whitespace setting to use |
154 | 154 |
|
155 | 155 | ### `Whitespace` |
156 | 156 |
|
@@ -185,12 +185,14 @@ openings for [cross-site scripting (XSS)][xss] attacks. |
185 | 185 |
|
186 | 186 | ## Related |
187 | 187 |
|
188 | | -* [`hast-util-to-string`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-to-string) |
189 | | - — get the plain-text value (`textContent`) |
190 | | -* [`hast-util-from-text`](https://github.com/syntax-tree/hast-util-from-text) |
191 | | - — set the plain-text value (`innerText`) |
192 | | -* [`hast-util-from-string`](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-from-string) |
193 | | - — set the plain-text value (`textContent`) |
| 188 | +* [`hast-util-to-string` |
| 189 | + ](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-to-string) |
| 190 | + — get the plain-text value (`textContent`) |
| 191 | +* [`hast-util-from-text`](https://github.com/syntax-tree/hast-util-from-text) |
| 192 | + — set the plain-text value (`innerText`) |
| 193 | +* [`hast-util-from-string` |
| 194 | + ](https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-from-string) |
| 195 | + — set the plain-text value (`textContent`) |
194 | 196 |
|
195 | 197 | ## Contribute |
196 | 198 |
|
|
0 commit comments