@@ -18,7 +18,9 @@ HTML) again, keeping positional info okay.
18
18
* [ Install] ( #install )
19
19
* [ Use] ( #use )
20
20
* [ API] ( #api )
21
- * [ ` raw(tree[, file][, options]) ` ] ( #rawtree-file-options )
21
+ * [ ` raw(tree[, options]) ` ] ( #rawtree-options )
22
+ * [ ` Options ` ] ( #options )
23
+ * [ ` Raw ` ] ( #raw )
22
24
* [ Types] ( #types )
23
25
* [ Compatibility] ( #compatibility )
24
26
* [ Security] ( #security )
@@ -63,7 +65,7 @@ The plugin [`rehype-raw`][rehype-raw] wraps this utility at a higher-level
63
65
## Install
64
66
65
67
This package is [ ESM only] [ esm ] .
66
- In Node.js (version 12.20+, 14.14+, 16.0+, or 18 .0+), install with [ npm] [ ] :
68
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
67
69
68
70
``` sh
69
71
npm install hast-util-raw
@@ -116,34 +118,56 @@ Yields:
116
118
117
119
## API
118
120
119
- This package exports the identifier ` raw ` .
121
+ This package exports the identifier [ ` raw ` ] [ raw ] .
120
122
There is no default export.
121
123
122
- ### ` raw(tree[, file][, options]) `
124
+ ### ` raw(tree[, options]) `
123
125
124
- Parse the tree and raw nodes (strings of HTML) again, keeping positional info
125
- okay .
126
+ Pass a hast tree through an HTML parser, which will fix nesting, and turn raw
127
+ nodes into actual nodes .
126
128
127
- > 👉 ** Note** : ` tree ` should have positional info and ` file ` , when given, must
128
- > be a [ vfile] [ ] corresponding to ` tree ` .
129
+ ###### Parameters
129
130
130
- ##### ` options `
131
+ * ` tree ` ([ ` Node ` ] [ node ] )
132
+ — original hast tree to transform
133
+ * ` options ` ([ ` Options ` ] [ options ] , optional)
134
+ — configuration
131
135
132
- Configuration (optional).
136
+ ###### Returns
133
137
134
- ###### ` options.passThrough `
138
+ Parsed again tree ( [ ` Node ` ] [ node ] ).
135
139
136
- List of custom hast node types to pass through (keep) in hast (` Array<string> ` ,
137
- default: ` [] ` ).
138
- If the passed through nodes have children, those children are expected to be
139
- hast and will be handled by this utility.
140
+ ### ` Options `
141
+
142
+ Configuration (TypeScript type).
143
+
144
+ ###### Fields
145
+
146
+ * ` passThrough ` (` Array<string> ` , optional)
147
+ — list of custom hast node types to pass through (keep).
148
+ If the passed through nodes have children, those children are expected to be
149
+ hast and will be handled by this utility
150
+ * ` file ` ([ ` VFile ` ] [ vfile ] , optional)
151
+ — corresponding virtual file representing the input document
152
+
153
+ ### ` Raw `
154
+
155
+ Interface of semistandard ` Raw ` nodes (TypeScript type).
156
+
157
+ ###### Type
158
+
159
+ ``` ts
160
+ export interface Raw extends Literal {
161
+ type: ' raw'
162
+ }
163
+ ```
140
164
141
165
## Types
142
166
143
167
This package is fully typed with [ TypeScript] [ ] .
144
- It exports the additional type ` Options ` .
168
+ It exports the additional types [ ` Options ` ] [ options ] and [ ` Raw ` ] [ raw-node ] .
145
169
146
- It also registers the ` Raw ` node type with ` @types/hast ` .
170
+ The types also register the ` Raw ` node type with ` @types/hast ` .
147
171
If you’re working with the syntax tree, make sure to import this utility
148
172
somewhere in your types, as that registers the new node types in the tree.
149
173
@@ -166,7 +190,7 @@ visit(tree, (node) => {
166
190
167
191
Projects maintained by the unified collective are compatible with all maintained
168
192
versions of Node.js.
169
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
193
+ As of now, that is Node.js 14.14+ and 16 .0+.
170
194
Our projects sometimes work with older versions, but this is not guaranteed.
171
195
172
196
## Security
@@ -262,10 +286,18 @@ abide by its terms.
262
286
263
287
[ hast ] : https://github.com/syntax-tree/hast
264
288
289
+ [ node ] : https://github.com/syntax-tree/hast#nodes
290
+
265
291
[ hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
266
292
267
293
[ vfile ] : https://github.com/vfile/vfile
268
294
269
295
[ rehype-raw ] : https://github.com/rehypejs/rehype-raw
270
296
271
297
[ parse5 ] : https://github.com/inikulin/parse5
298
+
299
+ [ raw ] : #rawtree-options
300
+
301
+ [ options ] : #options
302
+
303
+ [ raw-node ] : #raw
0 commit comments