@@ -46,7 +46,7 @@ The utility [`hast-util-from-html`][hast-util-from-html] wraps this utility and
46
46
## Install
47
47
48
48
This package is [ ESM only] [ esm ] .
49
- In Node.js (version 14.14+ and 16.0 +), install with [ npm] [ ] :
49
+ In Node.js (version 16 +), install with [ npm] [ ] :
50
50
51
51
``` sh
52
52
npm install hast-util-from-parse5
@@ -77,10 +77,10 @@ Say our document `example.html` contains:
77
77
…and our module ` example.js ` looks as follows:
78
78
79
79
``` js
80
+ import {fromParse5 } from ' hast-util-from-parse5'
80
81
import {parse } from ' parse5'
81
82
import {read } from ' to-vfile'
82
83
import {inspect } from ' unist-util-inspect'
83
- import {fromParse5 } from ' hast-util-from-parse5'
84
84
85
85
const file = await read (' example.html' )
86
86
const p5ast = parse (String (file), {sourceCodeLocationInfo: true })
@@ -94,9 +94,7 @@ console.log(inspect(hast))
94
94
``` text
95
95
root[2] (1:1-2:1, 0-70)
96
96
│ data: {"quirksMode":false}
97
- ├─0 doctype<html> (1:1-1:16, 0-15)
98
- │ public: null
99
- │ system: null
97
+ ├─0 doctype (1:1-1:16, 0-15)
100
98
└─1 element<html>[2]
101
99
│ properties: {}
102
100
├─0 element<head>[1]
@@ -115,7 +113,7 @@ root[2] (1:1-2:1, 0-70)
115
113
116
114
## API
117
115
118
- This package exports the identifier [ ` fromParse5 ` ] [ fromparse5 ] .
116
+ This package exports the identifier [ ` fromParse5 ` ] [ api-from-parse5 ] .
119
117
There is no default export.
120
118
121
119
### ` fromParse5(tree[, options]) `
@@ -126,7 +124,7 @@ Transform a `parse5` AST to hast.
126
124
127
125
* ` tree ` ([ ` Parse5Node ` ] [ parse5-node ] )
128
126
— ` parse5 ` tree to transform
129
- * ` options ` ([ ` Options ` ] [ options ] , optional)
127
+ * ` options ` ([ ` Options ` ] [ api- options] , optional)
130
128
— configuration
131
129
132
130
###### Returns
@@ -139,20 +137,20 @@ Configuration (TypeScript type).
139
137
140
138
##### Fields
141
139
140
+ ###### ` file `
141
+
142
+ File used to add positional info to nodes ([ ` VFile ` ] [ vfile ] , optional).
143
+
144
+ If given, the file should represent the original HTML source.
145
+
142
146
###### ` space `
143
147
144
- Which space the document is in ([ ` Space ` ] [ space ] , default: ` 'html' ` ).
148
+ Which space the document is in ([ ` Space ` ] [ api- space] , default: ` 'html' ` ).
145
149
146
150
When an ` <svg> ` element is found in the HTML space, this package already
147
151
automatically switches to and from the SVG space when entering and exiting
148
152
it.
149
153
150
- ###### ` file `
151
-
152
- File used to add positional info to nodes ([ ` VFile ` ] [ vfile ] , optional).
153
-
154
- If given, the file should represent the original HTML source.
155
-
156
154
###### ` verbose `
157
155
158
156
Whether to add extra positional info about starting tags, closing tags,
@@ -217,14 +215,18 @@ type Space = 'html' | 'svg'
217
215
## Types
218
216
219
217
This package is fully typed with [TypeScript][].
220
- It exports the additional types [ ` Options ` ][options] and [ ` Space ` ][space].
218
+ It exports the additional types [ ` Options ` ][api-options] and
219
+ [ ` Space ` ][api-space].
221
220
222
221
## Compatibility
223
222
224
- Projects maintained by the unified collective are compatible with all maintained
223
+ Projects maintained by the unified collective are compatible with maintained
225
224
versions of Node.js.
226
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
227
- Our projects sometimes work with older versions, but this is not guaranteed.
225
+
226
+ When we cut a new major release, we drop support for unmaintained versions of
227
+ Node.
228
+ This means we try to keep the current release line, ` hast -util -from -parse5 @^7 ` ,
229
+ compatible with Node.js 12.
228
230
229
231
## Security
230
232
@@ -274,9 +276,9 @@ abide by its terms.
274
276
275
277
[downloads]: https://www.npmjs.com/package/hast-util-from-parse5
276
278
277
- [size-badge]: https://img.shields.io/bundlephobia/minzip/ hast-util-from-parse5.svg
279
+ [size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-from-parse5
278
280
279
- [size]: https://bundlephobia .com/result?p =hast-util-from-parse5
281
+ [size]: https://bundlejs .com/?q =hast-util-from-parse5
280
282
281
283
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
282
284
@@ -324,8 +326,8 @@ abide by its terms.
324
326
325
327
[hast-node]: https://github.com/syntax-tree/hast#nodes
326
328
327
- [fromparse5 ]: #fromparse5tree-options
329
+ [api-from-parse5 ]: #fromparse5tree-options
328
330
329
- [options]: #options
331
+ [api- options]: #options
330
332
331
- [space]: #space-1
333
+ [api- space]: #space-1
0 commit comments