1
1
# hast-util-from-parse5
2
2
3
- [ ![ Build] [ build-badge ]] [ build ]
4
- [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5
- [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6
- [ ![ Size] [ size-badge ]] [ size ]
7
- [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8
- [ ![ Backers] [ backers-badge ]] [ collective ]
9
- [ ![ Chat] [ chat-badge ]] [ chat ]
3
+ [ ![ Build] [ badge-build-image ]] [ badge-build-url ]
4
+ [ ![ Coverage] [ badge-coverage-image ]] [ badge-coverage-url ]
5
+ [ ![ Downloads] [ badge-downloads-image ]] [ badge-downloads-url ]
6
+ [ ![ Size] [ badge-size-image ]] [ badge-size-url ]
10
7
11
- [ hast] [ ] utility to transform from [ ` parse5 ` ] [ parse5 ] s AST.
8
+ [ hast] [ github-hast ] utility to transform from the
9
+ [ ` parse5 ` ] [ github-parse5 ] AST.
12
10
13
11
## Contents
14
12
@@ -36,17 +34,17 @@ This package is a utility that can turn a parse5 tree into a hast tree.
36
34
You can use this package when using ` parse5 ` as an HTML parser and wanting to
37
35
work with hast.
38
36
39
- The utility [ ` hast-util-to-parse5 ` ] [ hast-util-to-parse5 ] does the inverse of
40
- this utility.
37
+ The utility [ ` hast-util-to-parse5 ` ] [ github- hast-util-to-parse5] does the
38
+ inverse of this utility.
41
39
It generates ` parse5 ` s AST again.
42
40
43
- The utility [ ` hast-util-from-html ` ] [ hast-util-from-html ] wraps this utility and
44
- ` parse5 ` to both parse HTML and generate hast from it.
41
+ The utility [ ` hast-util-from-html ` ] [ github- hast-util-from-html] wraps this
42
+ utility and ` parse5 ` to both parse HTML and generate hast from it.
45
43
46
44
## Install
47
45
48
- This package is [ ESM only] [ esm ] .
49
- In Node.js (version 16+), install with [ npm] [ ] :
46
+ This package is [ ESM only] [ github-gist- esm] .
47
+ In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
50
48
51
49
``` sh
52
50
npm install hast-util-from-parse5
@@ -122,14 +120,14 @@ Transform a `parse5` AST to hast.
122
120
123
121
###### Parameters
124
122
125
- * ` tree ` ([ ` Parse5Node ` ] [ parse5-node ] )
123
+ * ` tree ` ([ ` Parse5Node ` ] [ github- parse5-node] )
126
124
— ` parse5 ` tree to transform
127
125
* ` options ` ([ ` Options ` ] [ api-options ] , optional)
128
126
— configuration
129
127
130
128
###### Returns
131
129
132
- hast tree ([ ` HastNode ` ] [ hast-node ] ).
130
+ hast tree ([ ` HastNode ` ] [ github- hast-nodes ] ).
133
131
134
132
### ` Options `
135
133
@@ -139,7 +137,8 @@ Configuration (TypeScript type).
139
137
140
138
###### ` file `
141
139
142
- File used to add positional info to nodes ([ ` VFile ` ] [ vfile ] , optional).
140
+ File used to add positional info to nodes
141
+ ([ ` VFile ` ] [ github-vfile ] , optional).
143
142
144
143
If given, the file should represent the original HTML source.
145
144
@@ -231,11 +230,11 @@ compatible with Node.js 16.
231
230
## Security
232
231
233
232
Use of ` hast -util -from -parse5 ` can open you up to a
234
- [cross-site scripting (XSS)][xss] attack if Parse5’s AST is unsafe.
233
+ [cross-site scripting (XSS)][wikipedia- xss] attack if Parse5’s AST is unsafe.
235
234
236
235
## Related
237
236
238
- * [ ` hast -util -to -parse5 ` ](https:// github.com/syntax-tree/ hast-util-to-parse5)
237
+ * [ ` hast -util -to -parse5 ` ][ github- hast-util-to-parse5]
239
238
— transform hast to Parse5’s AST
240
239
* [ ` hast -util -to -nlcst ` ](https://github.com/syntax-tree/hast-util-to-nlcst)
241
240
— transform hast to nlcst
@@ -250,84 +249,76 @@ Use of `hast-util-from-parse5` can open you up to a
250
249
251
250
## Contribute
252
251
253
- See [ ` contributing .md ` ][contributing] in [ ` syntax -tree /.github ` ][health] for
254
- ways to get started.
255
- See [ ` support .md ` ][support] for ways to get help.
252
+ See [ ` contributing .md ` ][health-contributing]
253
+ in
254
+ [ ` syntax -tree /.github ` ][health]
255
+ for ways to get started.
256
+ See [ ` support .md ` ][health-support] for ways to get help.
256
257
257
- This project has a [code of conduct][coc].
258
+ This project has a [code of conduct][health- coc].
258
259
By interacting with this repository, organization, or community you agree to
259
260
abide by its terms.
260
261
261
262
## License
262
263
263
- [MIT][license] © [Titus Wormer][author ]
264
+ [MIT][file- license] © [Titus Wormer][wooorm ]
264
265
265
266
<!-- Definitions -->
266
267
267
- [build-badge]: https://github.com/syntax-tree/hast-util-from-parse5/workflows/main/badge.svg
268
-
269
- [build]: https://github.com/syntax-tree/hast-util-from-parse5/actions
270
-
271
- [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-from-parse5.svg
272
-
273
- [coverage]: https://codecov.io/github/syntax-tree/hast-util-from-parse5
274
-
275
- [downloads-badge]: https://img.shields.io/npm/dm/hast-util-from-parse5.svg
268
+ [api-from-parse5]: #fromparse5tree-options
276
269
277
- [downloads ]: https://www.npmjs.com/package/hast-util-from-parse5
270
+ [api-options ]: #options
278
271
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
272
+ [api-space ]: #space-1
280
273
281
- [size ]: https://bundlejs .com/?q= hast-util-from-parse5
274
+ [badge-build-image ]: https://github .com/syntax-tree/ hast-util-from-parse5/workflows/main/badge.svg
282
275
283
- [sponsors- badge]: https://opencollective .com/unified/sponsors/badge.svg
276
+ [badge-build-url ]: https://github .com/syntax-tree/hast-util-from-parse5/actions
284
277
285
- [backers- badge]: https://opencollective.com/unified/backers/badge .svg
278
+ [badge-coverage-image ]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-from-parse5 .svg
286
279
287
- [collective ]: https://opencollective.com/unified
280
+ [badge-coverage-url ]: https://codecov.io/github/syntax-tree/hast-util-from-parse5
288
281
289
- [chat- badge]: https://img.shields.io/badge/chat-discussions-success .svg
282
+ [badge-downloads-image ]: https://img.shields.io/npm/dm/hast-util-from-parse5 .svg
290
283
291
- [chat ]: https://github. com/syntax-tree/unist/discussions
284
+ [badge-downloads-url ]: https://www.npmjs. com/package/hast-util-from-parse5
292
285
293
- [npm ]: https://docs.npmjs.com/cli/install
286
+ [badge-size-image ]: https://img.shields.io/bundlejs/size/hast-util-from-parse5
294
287
295
- [esm ]: https://gist.github. com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
288
+ [badge-size-url ]: https://bundlejs. com/?q=hast-util-from-parse5
296
289
297
290
[esmsh]: https://esm.sh
298
291
299
- [typescript ]: https://www.typescriptlang.org
292
+ [file-license ]: license
300
293
301
- [license ]: license
294
+ [github-gist-esm ]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
302
295
303
- [author ]: https://wooorm .com
296
+ [github-hast ]: https://github .com/syntax-tree/hast
304
297
305
- [health]: https://github.com/syntax-tree/.github
306
-
307
- [contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
298
+ [github-hast-nodes]: https://github.com/syntax-tree/hast#nodes
308
299
309
- [support ]: https://github.com/syntax-tree/.github/blob/main/support.md
300
+ [github-hast-util-from-html ]: https://github.com/syntax-tree/hast-util-from-html
310
301
311
- [coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
302
+ [github-hast-util-to-parse5 ]: https://github.com/syntax-tree/hast-util-to-parse5
312
303
313
- [xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
304
+ [github-parse5 ]: https://github.com/inikulin/parse5
314
305
315
- [parse5]: https://github.com/inikulin/parse5
306
+ [github- parse5-node ]: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/tree-adapters/default.ts
316
307
317
- [parse5-node ]: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/tree-adapters/default.ts
308
+ [github-vfile ]: https://github.com/vfile/vfile
318
309
319
- [vfile ]: https://github.com/vfile/vfile
310
+ [health ]: https://github.com/syntax-tree/.github
320
311
321
- [hast-util-to-parse5 ]: https://github.com/syntax-tree/hast-util-to-parse5
312
+ [health-coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
322
313
323
- [hast ]: https://github.com/syntax-tree/hast
314
+ [health-contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
324
315
325
- [hast-util-from-html ]: https://github.com/syntax-tree/hast-util-from-html
316
+ [health-support ]: https://github.com/syntax-tree/.github/blob/main/support.md
326
317
327
- [hast-node ]: https://github. com/syntax-tree/hast#nodes
318
+ [npmjs-install ]: https://docs.npmjs. com/cli/install
328
319
329
- [api-from-parse5 ]: #fromparse5tree-options
320
+ [typescript ]: https://www.typescriptlang.org
330
321
331
- [api-options ]: #options
322
+ [wikipedia-xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
332
323
333
- [api-space ]: #space-1
324
+ [wooorm ]: https://wooorm.com
0 commit comments