11# hast-util-to-html
22
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 ]
107
11- [ hast] [ ] utility to serialize hast as HTML.
8+ [ hast] [ github-hast ] utility to serialize hast as HTML.
129
1310## Contents
1411
@@ -45,17 +42,18 @@ This utility has many options to configure how the HTML is serialized.
4542These options help when building tools that make output pretty (such as
4643formatters) or ugly (such as minifiers).
4744
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.
5047It turns HTML into hast.
5148
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.
5451
5552## Install
5653
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 ] :
5957
6058``` sh
6159npm install hast-util-to-html
@@ -64,27 +62,19 @@ npm install hast-util-to-html
6462In Deno with [ ` esm.sh ` ] [ esmsh ] :
6563
6664``` 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'
6866```
6967
7068In browsers with [ ` esm.sh ` ] [ esmsh ] :
7169
7270``` html
7371<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'
7573 </script >
7674```
7775
7876## Use
7977
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-
8878``` js
8979import {h } from ' hastscript'
9080import {toHtml } from ' hast-util-to-html'
@@ -116,7 +106,7 @@ Serialize hast as HTML.
116106
117107###### Parameters
118108
119- * ` tree ` ([ ` Node ` ] [ node ] or ` Array<Node> ` )
109+ * ` tree ` ([ ` Node ` ] [ github-hast-nodes ] or ` Array<Node> ` )
120110 — tree to serialize
121111* ` options ` ([ ` Options ` ] [ api-options ] , optional)
122112 — configuration
@@ -262,7 +252,7 @@ automatically switches to and from the SVG space when entering and exiting it.
262252> It supports SVG as embedded in HTML.
263253> It does not support the features available in XML.
264254> 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.
266256
267257###### ` tightAttributes `
268258
@@ -306,7 +296,7 @@ Useless except for XHTML.
306296###### ` voids `
307297
308298Tag 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] ).
310300
311301Not used in the SVG space.
312302
@@ -360,98 +350,91 @@ compatible with Node.js 16.
360350## Security
361351
362352Use 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.
365356
366357## Related
367358
368- * [ ` hast -util -sanitize ` ](https:// github.com/syntax-tree/ hast-util-sanitize)
359+ * [ ` hast -util -sanitize ` ][ github- hast-util-sanitize]
369360 — sanitize hast
370361
371362## Contribute
372363
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.
376369
377- This project has a [code of conduct][coc].
370+ This project has a [code of conduct][health- coc].
378371By interacting with this repository, organization, or community you agree to
379372abide by its terms.
380373
381374## License
382375
383- [MIT][license] © [Titus Wormer][author ]
376+ [MIT][file- license] © [Titus Wormer][wooorm ]
384377
385378<!-- Definitions -->
386379
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
392381
393- [coverage ]: https://codecov.io/github/syntax-tree/hast-util-to-html
382+ [api-options ]: #options
394383
395- [downloads-badge ]: https://img.shields.io/npm/dm/hast-util-to-html.svg
384+ [api-quote ]: #quote-1
396385
397- [downloads ]: https://www.npmjs.com/package/hast-util-to-html
386+ [api-space ]: #space-1
398387
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
400389
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
402391
403- [sponsors- badge]: https://opencollective .com/unified/sponsors/badge.svg
392+ [badge-build-url ]: https://github .com/syntax-tree/hast-util-to-html/actions
404393
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
406395
407- [collective ]: https://opencollective.com/unified
396+ [badge-coverage-url ]: https://codecov.io/github/syntax-tree/hast-util-to-html
408397
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
410399
411- [chat ]: https://github. com/syntax-tree/unist/discussions
400+ [badge-downloads-url ]: https://www.npmjs. com/package/hast-util-to-html
412401
413- [npm ]: https://docs.npmjs.com/cli/install
402+ [badge-size-image ]: https://img.shields.io/bundlejs/size/hast-util-to-html
414403
415- [esm ]: https://gist.github. com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
404+ [badge-size-url ]: https://bundlejs. com/?q=hast-util-to-html
416405
417406[esmsh]: https://esm.sh
418407
419- [typescript]: https://www.typescriptlang.org
420-
421- [license]: license
422-
423- [author]: https://wooorm.com
408+ [file-license]: license
424409
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
428411
429- [support ]: https://github.com/syntax-tree/.github/blob/main/support.md
412+ [github-hast ]: https://github.com/syntax-tree/hast
430413
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
432415
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
434417
435- [hast]: https://github.com/syntax-tree/hast
418+ [github- hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
436419
437- [node ]: https://github.com/syntax-tree/hast#nodes
420+ [github-html-void-elements ]: https://github.com/wooorm/html-void-elements
438421
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
440423
441- [hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
424+ [github-xast ]: https://github.com/syntax-tree/xast
442425
443- [hast-util-from-html ]: https://github.com/syntax-tree/hast-util-from-html
426+ [health ]: https://github.com/syntax-tree/.github
444427
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
446429
447- [xast ]: https://github.com/syntax-tree/xast
430+ [health-contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
448431
449- [api-to-html ]: #tohtmltree-options
432+ [health-support ]: https://github.com/syntax-tree/.github/blob/main/support.md
450433
451- [api-character-references ]: #characterreferences
434+ [npmjs-install ]: https://docs.npmjs.com/cli/install
452435
453- [api-options ]: #options
436+ [typescript ]: https://www.typescriptlang.org
454437
455- [api-space ]: #space-1
438+ [wikipedia-xss ]: https://en.wikipedia.org/wiki/Cross-site_scripting
456439
457- [api-quote ]: #quote-1
440+ [wooorm ]: https://wooorm.com
0 commit comments