8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ hast] [ ] utility to generate [ ` parse5 ` ] [ parse5 ] s [ AST] [ ] .
11
+ [ hast] [ ] utility to generate [ ` parse5 ` ] [ parse5 ] s [ AST] [ parse5-node ] .
12
12
13
13
## Contents
14
14
17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` toParse5(tree[, space]) ` ] ( #toparse5tree-space )
20
+ * [ ` toParse5(tree[, space|options]) ` ] ( #toparse5tree-spaceoptions )
21
+ * [ ` Options ` ] ( #options )
22
+ * [ ` Space ` ] ( #space )
21
23
* [ Types] ( #types )
22
24
* [ Compatibility] ( #compatibility )
23
25
* [ Security] ( #security )
@@ -41,7 +43,7 @@ likely what you want.
41
43
## Install
42
44
43
45
This package is [ ESM only] [ esm ] .
44
- In Node.js (version 12.20+, 14.14+, 16.0+, or 18 .0+), install with [ npm] [ ] :
46
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
45
47
46
48
``` sh
47
49
npm install hast-util-to-parse5
@@ -88,32 +90,55 @@ Yields:
88
90
89
91
## API
90
92
91
- This package exports the identifier ` toParse5 ` .
93
+ This package exports the identifier [ ` toParse5 ` ] [ toparse5 ] .
92
94
There is no default export.
93
95
94
- ### ` toParse5(tree[, space]) `
96
+ ### ` toParse5(tree[, space|options ]) `
95
97
96
- [ hast ] [ ] utility to transform to [ ` parse5 ` ] [ parse5 ] s [ ast ] [ ] .
98
+ Transform a hast tree to Parse5’s AST .
97
99
98
- ###### ` space `
100
+ ###### Parameters
99
101
100
- Whether the root of the given tree is in the HTML or SVG space (enum, ` 'svg' ` or
101
- ` 'html' ` , default: ` 'html' ` ).
102
+ * ` tree ` ([ ` HastNode ` ] [ hast-node ] )
103
+ — tree to transform
104
+ * ` space ` ([ ` Space ` ] [ space ] , optional)
105
+ — same as ` {space: space} `
106
+ * ` options ` ([ ` Options ` ] [ options ] , optional)
107
+ — configuration
102
108
103
- If an ` svg ` element is found in the HTML space, ` toParse5 ` automatically
104
- switches to the SVG space when entering the element, and switches back when
105
- exiting.
109
+ ###### Returns
110
+
111
+ ` parse5 ` node ([ ` Parse5Node ` ] [ parse5-node ] ).
112
+
113
+ ### ` Options `
114
+
115
+ Configuration (TypeScript type).
116
+
117
+ ###### Fields
118
+
119
+ * ` space ` ([ ` Space ` ] [ space ] , optional)
120
+ — which space the document is in
121
+
122
+ ### ` Space `
123
+
124
+ Namespace (TypeScript type).
125
+
126
+ ###### Type
127
+
128
+ ``` ts
129
+ type Space = ' html' | ' svg'
130
+ ` ` `
106
131
107
132
## Types
108
133
109
134
This package is fully typed with [TypeScript][].
110
- It exports the additional type ` Space ` .
135
+ It exports the additional types [ ` Options ` ][options] and [ ` Space ` ][space] .
111
136
112
137
## Compatibility
113
138
114
139
Projects maintained by the unified collective are compatible with all maintained
115
140
versions of Node.js.
116
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
141
+ As of now, that is Node.js 14.14+ and 16 .0+.
117
142
Our projects sometimes work with older versions, but this is not guaranteed.
118
143
119
144
## Security
@@ -198,12 +223,20 @@ abide by its terms.
198
223
199
224
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
200
225
226
+ [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
227
+
201
228
[hast]: https://github.com/syntax-tree/hast
202
229
203
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
230
+ [hast-node ]: https://github.com/syntax-tree/hast#nodes
204
231
205
232
[parse5]: https://github.com/inikulin/parse5
206
233
207
- [ ast ] : https://github.com/inikulin/parse5/wiki/Documentation
234
+ [parse5-node ]: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/tree-adapters/default.ts
208
235
209
236
[hast-util-from-parse5]: https://github.com/syntax-tree/hast-util-from-parse5
237
+
238
+ [toparse5]: #toparse5tree-spaceoptions
239
+
240
+ [options]: #options
241
+
242
+ [space]: #space
0 commit comments