1
1
# hast-util-to-html
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 serialize hast as HTML.
8
+ [ hast] [ github-hast ] utility to serialize hast as HTML.
12
9
13
10
## Contents
14
11
@@ -45,17 +42,18 @@ This utility has many options to configure how the HTML is serialized.
45
42
These options help when building tools that make output pretty (such as
46
43
formatters) or ugly (such as minifiers).
47
44
48
- The utility [ ` hast-util-from-html ` ] [ hast-util-from-html ] does the inverse of
49
- this utility.
45
+ The utility [ ` hast-util-from-html ` ] [ github- hast-util-from-html] does the
46
+ inverse of this utility.
50
47
It turns HTML into hast.
51
48
52
- The rehype plugin [ ` rehype-stringify ` ] [ rehype-stringify ] wraps this utility to
53
- also serialize HTML at a higher-level (easier) abstraction.
49
+ The rehype plugin [ ` rehype-stringify ` ] [ github- rehype-stringify] wraps this
50
+ utility to also serialize HTML at a higher-level (easier) abstraction.
54
51
55
52
## Install
56
53
57
- This package is [ ESM only] [ esm ] .
58
- In Node.js (version 16+), install with [ npm] [ ] :
54
+ This package is [ ESM only] [ github-gist-esm ] .
55
+ In Node.js (version 16+),
56
+ install with [ npm] [ npmjs-install ] :
59
57
60
58
``` sh
61
59
npm install hast-util-to-html
@@ -64,27 +62,19 @@ npm install hast-util-to-html
64
62
In Deno with [ ` esm.sh ` ] [ esmsh ] :
65
63
66
64
``` js
67
- import {toHtml } from " https://esm.sh/hast-util-to-html@9"
65
+ import {toHtml } from ' https://esm.sh/hast-util-to-html@9'
68
66
```
69
67
70
68
In browsers with [ ` esm.sh ` ] [ esmsh ] :
71
69
72
70
``` html
73
71
<script type =" module" >
74
- import {toHtml } from " https://esm.sh/hast-util-to-html@9?bundle"
72
+ import {toHtml } from ' https://esm.sh/hast-util-to-html@9?bundle'
75
73
</script >
76
74
```
77
75
78
76
## Use
79
77
80
- <details ><summary >Show install command for this example</summary >
81
-
82
- ``` sh
83
- npm install hastscript hast-util-to-html
84
- ```
85
-
86
- </details >
87
-
88
78
``` js
89
79
import {h } from ' hastscript'
90
80
import {toHtml } from ' hast-util-to-html'
@@ -116,7 +106,7 @@ Serialize hast as HTML.
116
106
117
107
###### Parameters
118
108
119
- * ` tree ` ([ ` Node ` ] [ node ] or ` Array<Node> ` )
109
+ * ` tree ` ([ ` Node ` ] [ github-hast-nodes ] or ` Array<Node> ` )
120
110
— tree to serialize
121
111
* ` options ` ([ ` Options ` ] [ api-options ] , optional)
122
112
— configuration
@@ -262,7 +252,7 @@ automatically switches to and from the SVG space when entering and exiting it.
262
252
> It supports SVG as embedded in HTML.
263
253
> It does not support the features available in XML.
264
254
> Passing SVG might break but fragments of modern SVG should be fine.
265
- > Use [ ` xast ` ] [ xast ] if you need to support SVG as XML.
255
+ > Use [ ` xast ` ] [ github- xast] if you need to support SVG as XML.
266
256
267
257
###### ` tightAttributes `
268
258
@@ -306,7 +296,7 @@ Useless except for XHTML.
306
296
###### ` voids `
307
297
308
298
Tag names of elements to serialize without closing tag (` Array<string> ` ,
309
- default: [ ` html-void-elements ` ] [ html-void-elements ] ).
299
+ default: [ ` html-void-elements ` ] [ github- html-void-elements] ).
310
300
311
301
Not used in the SVG space.
312
302
@@ -360,98 +350,91 @@ compatible with Node.js 16.
360
350
## Security
361
351
362
352
Use of ` hast -util -to -html ` can open you up to a
363
- [cross-site scripting (XSS)][xss] attack if the hast tree is unsafe.
364
- Use [ ` hast -util -santize ` ][hast-util-sanitize] to make the hast tree safe.
353
+ [cross-site scripting (XSS)][wikipedia-xss] attack if the hast tree is unsafe.
354
+ Use [ ` hast -util -santize ` ][github-hast-util-sanitize] to make the hast tree
355
+ safe.
365
356
366
357
## Related
367
358
368
- * [ ` hast -util -sanitize ` ](https:// github.com/syntax-tree/ hast-util-sanitize)
359
+ * [ ` hast -util -sanitize ` ][ github- hast-util-sanitize]
369
360
— sanitize hast
370
361
371
362
## Contribute
372
363
373
- See [ ` contributing .md ` ][contributing] in [ ` syntax -tree /.github ` ][health] for
374
- ways to get started.
375
- See [ ` support .md ` ][support] for ways to get help.
364
+ See [ ` contributing .md ` ][health-contributing]
365
+ in
366
+ [ ` syntax -tree /.github ` ][health]
367
+ for ways to get started.
368
+ See [ ` support .md ` ][health-support] for ways to get help.
376
369
377
- This project has a [code of conduct][coc].
370
+ This project has a [code of conduct][health- coc].
378
371
By interacting with this repository, organization, or community you agree to
379
372
abide by its terms.
380
373
381
374
## License
382
375
383
- [MIT][license] © [Titus Wormer][author ]
376
+ [MIT][file- license] © [Titus Wormer][wooorm ]
384
377
385
378
<!-- Definitions -->
386
379
387
- [build-badge]: https://github.com/syntax-tree/hast-util-to-html/workflows/main/badge.svg
388
-
389
- [build]: https://github.com/syntax-tree/hast-util-to-html/actions
390
-
391
- [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-html.svg
380
+ [api-character-references]: #characterreferences
392
381
393
- [coverage ]: https://codecov.io/github/syntax-tree/hast-util-to-html
382
+ [api-options ]: #options
394
383
395
- [downloads-badge ]: https://img.shields.io/npm/dm/hast-util-to-html.svg
384
+ [api-quote ]: #quote-1
396
385
397
- [downloads ]: https://www.npmjs.com/package/hast-util-to-html
386
+ [api-space ]: #space-1
398
387
399
- [size-badge ]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-to-html
388
+ [api-to-html ]: #tohtmltree-options
400
389
401
- [size ]: https://bundlejs .com/?q= hast-util-to-html
390
+ [badge-build-image ]: https://github .com/syntax-tree/ hast-util-to-html/workflows/main/badge.svg
402
391
403
- [sponsors- badge]: https://opencollective .com/unified/sponsors/badge.svg
392
+ [badge-build-url ]: https://github .com/syntax-tree/hast-util-to-html/actions
404
393
405
- [backers- badge]: https://opencollective.com/unified/backers/badge .svg
394
+ [badge-coverage-image ]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-html .svg
406
395
407
- [collective ]: https://opencollective.com/unified
396
+ [badge-coverage-url ]: https://codecov.io/github/syntax-tree/hast-util-to-html
408
397
409
- [chat- badge]: https://img.shields.io/badge/chat-discussions-success .svg
398
+ [badge-downloads-image ]: https://img.shields.io/npm/dm/hast-util-to-html .svg
410
399
411
- [chat ]: https://github. com/syntax-tree/unist/discussions
400
+ [badge-downloads-url ]: https://www.npmjs. com/package/hast-util-to-html
412
401
413
- [npm ]: https://docs.npmjs.com/cli/install
402
+ [badge-size-image ]: https://img.shields.io/bundlejs/size/hast-util-to-html
414
403
415
- [esm ]: https://gist.github. com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
404
+ [badge-size-url ]: https://bundlejs. com/?q=hast-util-to-html
416
405
417
406
[esmsh]: https://esm.sh
418
407
419
- [typescript]: https://www.typescriptlang.org
420
-
421
- [license]: license
422
-
423
- [author]: https://wooorm.com
408
+ [file-license]: license
424
409
425
- [health]: https://github.com/syntax-tree/.github
426
-
427
- [contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
410
+ [github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
428
411
429
- [support ]: https://github.com/syntax-tree/.github/blob/main/support.md
412
+ [github-hast ]: https://github.com/syntax-tree/hast
430
413
431
- [coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
414
+ [github-hast-nodes ]: https://github.com/syntax-tree/hast#nodes
432
415
433
- [xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
416
+ [github-hast-util-from-html ]: https://github.com/syntax-tree/hast-util-from-html
434
417
435
- [hast]: https://github.com/syntax-tree/hast
418
+ [github- hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
436
419
437
- [node ]: https://github.com/syntax-tree/hast#nodes
420
+ [github-html-void-elements ]: https://github.com/wooorm/html-void-elements
438
421
439
- [html-void-elements ]: https://github.com/wooorm/html-void-elements
422
+ [github-rehype-stringify ]: https://github.com/rehypejs/rehype/tree/main/packages/rehype-stringify#readme
440
423
441
- [hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
424
+ [github-xast ]: https://github.com/syntax-tree/xast
442
425
443
- [hast-util-from-html ]: https://github.com/syntax-tree/hast-util-from-html
426
+ [health ]: https://github.com/syntax-tree/.github
444
427
445
- [rehype-stringify ]: https://github.com/rehypejs/rehype/tree /main/packages/rehype-stringify#readme
428
+ [health-coc ]: https://github.com/syntax-tree/.github/blob /main/code-of-conduct.md
446
429
447
- [xast ]: https://github.com/syntax-tree/xast
430
+ [health-contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
448
431
449
- [api-to-html ]: #tohtmltree-options
432
+ [health-support ]: https://github.com/syntax-tree/.github/blob/main/support.md
450
433
451
- [api-character-references ]: #characterreferences
434
+ [npmjs-install ]: https://docs.npmjs.com/cli/install
452
435
453
- [api-options ]: #options
436
+ [typescript ]: https://www.typescriptlang.org
454
437
455
- [api-space ]: #space-1
438
+ [wikipedia-xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
456
439
457
- [api-quote ]: #quote-1
440
+ [wooorm ]: https://wooorm.com
0 commit comments