8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** hast** ] [ hast ] utility to transform to [ Parse5’s AST] [ ast ] .
11
+ [ hast] [ ] utility to generate [ ` parse5 ` ] [ parse5 ] s [ AST] [ ] .
12
12
13
- > ** Q** : Why not use a Parse5 adapter?
14
- > ** A** : Because it’s more code weight to use adapters, and much more fragile.
13
+ ## Contents
15
14
16
- ## Install
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
+ * [ ` toParse5(tree[, space]) ` ] ( #toparse5tree-space )
21
+ * [ Types] ( #types )
22
+ * [ Compatibility] ( #compatibility )
23
+ * [ Security] ( #security )
24
+ * [ Related] ( #related )
25
+ * [ Contribute] ( #contribute )
26
+ * [ License] ( #license )
27
+
28
+ ## What is this?
17
29
18
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
19
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
30
+ This package is a utility that can turn a hast syntax tree into ` parse5 ` s AST.
31
+ Why not use a Parse5 adapter, you might ask?
32
+ Well, because it’s more code weight to use adapters, and more fragile.
20
33
21
- [ npm] [ ] :
34
+ ## When should I use this?
35
+
36
+ This package is useful when working with ` parse5 ` , and for some reason want to
37
+ generate its AST again.
38
+ The inverse utility, [ ` hast-util-from-parse5 ` ] [ hast-util-from-parse5 ] , is more
39
+ likely what you want.
40
+
41
+ ## Install
42
+
43
+ This package is [ ESM only] [ esm ] .
44
+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
22
45
23
46
``` sh
24
47
npm install hast-util-to-parse5
25
48
```
26
49
50
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
51
+
52
+ ``` js
53
+ import {toParse5 } from ' https://esm.sh/hast-util-to-parse5@7'
54
+ ```
55
+
56
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
57
+
58
+ ``` html
59
+ <script type =" module" >
60
+ import {toParse5 } from ' https://esm.sh/hast-util-to-parse5@7?bundle'
61
+ </script >
62
+ ```
63
+
27
64
## Use
28
65
29
66
``` js
@@ -51,22 +88,34 @@ Yields:
51
88
52
89
## API
53
90
54
- This package exports the following identifiers: ` toParse5 ` .
91
+ This package exports the identifier ` toParse5 ` .
55
92
There is no default export.
56
93
57
94
### ` toParse5(tree[, space]) `
58
95
59
- Transform a [ ** hast** ] [ hast ] [ * tree * ] [ tree ] to [ Parse5’s AST ] [ ast ] .
96
+ [ hast] [ ] utility to transform to [ ` parse5 ` ] [ parse5 ] s [ ast] [ ] .
60
97
61
98
###### ` space `
62
99
63
- Whether the root of the given [ * tree* ] [ tree ] is in the ` 'html' ` or ` 'svg' ` space
64
- (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` ).
100
+ Whether the root of the given tree is in the HTML or SVG space (enum, ` 'svg' ` or
101
+ ` 'html' ` , default: ` 'html' ` ).
65
102
66
103
If an ` svg ` element is found in the HTML space, ` toParse5 ` automatically
67
104
switches to the SVG space when entering the element, and switches back when
68
105
exiting.
69
106
107
+ ## Types
108
+
109
+ This package is fully typed with [ TypeScript] [ ] .
110
+ It exports the additional type ` Space ` .
111
+
112
+ ## Compatibility
113
+
114
+ Projects maintained by the unified collective are compatible with all maintained
115
+ versions of Node.js.
116
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
117
+ Our projects sometimes work with older versions, but this is not guaranteed.
118
+
70
119
## Security
71
120
72
121
Use of ` hast-util-to-parse5 ` can open you up to a
@@ -89,8 +138,8 @@ Use of `hast-util-to-parse5` can open you up to a
89
138
90
139
## Contribute
91
140
92
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
93
- started.
141
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
142
+ ways to get started.
94
143
See [ ` support.md ` ] [ support ] for ways to get help.
95
144
96
145
This project has a [ code of conduct] [ coc ] .
@@ -131,20 +180,30 @@ abide by its terms.
131
180
132
181
[ npm ] : https://docs.npmjs.com/cli/install
133
182
183
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
184
+
185
+ [ esmsh ] : https://esm.sh
186
+
187
+ [ typescript ] : https://www.typescriptlang.org
188
+
134
189
[ license ] : license
135
190
136
191
[ author ] : https://wooorm.com
137
192
138
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
193
+ [ health ] : https://github.com/syntax-tree/.github
139
194
140
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
195
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
141
196
142
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct .md
197
+ [ support ] : https://github.com/syntax-tree/.github/blob/main/support .md
143
198
144
- [ ast ] : https://github.com/inikulin/parse5/wiki/Documentation
145
-
146
- [ tree ] : https://github.com/syntax-tree/unist#tree
199
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
147
200
148
201
[ hast ] : https://github.com/syntax-tree/hast
149
202
150
203
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
204
+
205
+ [ parse5 ] : https://github.com/inikulin/parse5
206
+
207
+ [ ast ] : https://github.com/inikulin/parse5/wiki/Documentation
208
+
209
+ [ hast-util-from-parse5 ] : https://github.com/syntax-tree/hast-util-from-parse5
0 commit comments