33[ ![ Build] [ build-badge ]] [ build ]
44[ ![ Coverage] [ coverage-badge ]] [ coverage ]
55[ ![ Downloads] [ downloads-badge ]] [ downloads ]
6+ [ ![ Size] [ size-badge ]] [ size ]
7+ [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8+ [ ![ Backers] [ backers-badge ]] [ collective ]
69[ ![ Chat] [ chat-badge ]] [ chat ]
710
8- Transform [ HAST ] [ ] to HTML.
11+ [ ** hast ** ] [ hast ] utility to transform to HTML.
912
10- ## Installation
13+ ## Install
1114
1215[ npm] [ ] :
1316
14- ``` bash
17+ ``` sh
1518npm install hast-util-to-html
1619```
1720
1821## Usage
1922
20- ``` javascript
23+ ``` js
2124var h = require (' hastscript' )
2225var toHTML = require (' hast-util-to-html' )
2326
@@ -41,27 +44,29 @@ Yields:
4144
4245### ` toHTML(tree[, options]) `
4346
44- Stringify the given [ HAST tree] [ hast ] .
47+ Stringify the given [ ** hast ** ] [ hast ] [ * tree* ] [ tree ] .
4548
4649###### ` options.space `
4750
48- Whether the root of the given tree is in the ` 'html' ` or ` 'svg' ` space (enum,
49- ` 'svg' ` or ` 'html' ` , default: ` 'html' ` ).
51+ Whether the [ * root* ] [ root ] of the [ * tree* ] [ tree ] is in the ` 'html' ` or ` 'svg' `
52+ space (enum, ` 'svg' ` or ` 'html' ` , default: ` 'html' ` ).
5053
5154If an ` svg ` element is found in the HTML space, ` toHTML ` automatically switches
52- to the SVG space when entering the element, and switches back when leaving .
55+ to the SVG space when entering the element, and switches back when exiting .
5356
5457###### ` options.entities `
5558
56- Configuration for [ ` stringify-entities ` ] [ stringify-entities ]
57- (` Object ` , default: ` {} ` ). Do not use ` escapeOnly ` , ` attribute ` , or
58- ` subset ` (` toHTML ` already passes those). However, ` useNamedReferences ` ,
59- ` useShortestReferences ` , and ` omitOptionalSemicolons ` are all fine.
59+ Configuration for [ ` stringify-entities ` ] [ stringify-entities ] (` Object ` , default:
60+ ` {} ` ).
61+ Do not use ` escapeOnly ` , ` attribute ` , or ` subset ` (` toHTML ` already passes
62+ those, so they won’t work).
63+ However, ` useNamedReferences ` , ` useShortestReferences ` , and
64+ ` omitOptionalSemicolons ` are all fine.
6065
6166###### ` options.voids `
6267
63- Tag- names of elements to stringify without closing tag ( ` Array.<string> ` ,
64- default: [ ` html-void-elements ` ] [ html-void-elements ] ).
68+ Tag names of [ * elements* ] [ element ] to stringify without closing tag
69+ ( ` Array.<string> ` , default: [ ` html-void-elements ` ] [ html-void-elements ] ).
6570
6671Not used in the SVG space.
6772
@@ -71,37 +76,38 @@ Preferred quote to use (`'"'` or `'\''`, default: `'"'`).
7176
7277###### ` options.quoteSmart `
7378
74- Use the other quote if that results in less bytes (` boolean ` , default:
75- ` false ` ).
79+ Use the other quote if that results in less bytes (` boolean ` , default: ` false ` ).
7680
7781###### ` options.preferUnquoted `
7882
79- Leave attributes unquoted if that results in less bytes (` boolean ` ,
80- default: ` false ` ).
83+ Leave attributes unquoted if that results in less bytes (` boolean ` , default:
84+ ` false ` ).
8185
8286Not used in the SVG space.
8387
8488###### ` options.omitOptionalTags `
8589
8690Omit optional opening and closing tags (` boolean ` , default: ` false ` ).
8791For example, in ` <ol><li>one</li><li>two</li></ol> ` , both ` </li> `
88- closing tags can be omitted. The first because it’s followed by
89- another ` li ` , the last because it’s followed by nothing.
92+ closing tags can be omitted.
93+ The first because it’s followed by another ` li ` , the last because it’s followed
94+ by nothing.
9095
9196Not used in the SVG space.
9297
9398###### ` options.collapseEmptyAttributes `
9499
95100Collapse empty attributes: ` class="" ` is stringified as ` class ` instead
96- (` boolean ` , default: ` false ` ). ** Note ** : boolean attributes, such as
97- ` hidden ` , are always collapsed.
101+ (` boolean ` , default: ` false ` ).
102+ ** Note ** : boolean attributes, such as ` hidden ` , are always collapsed.
98103
99104Not used in the SVG space.
100105
101106###### ` options.closeSelfClosing `
102107
103108Close self-closing nodes with an extra slash (` / ` ): ` <img /> ` instead of
104109` <img> ` (` boolean ` , default: ` false ` ).
110+ See ` tightSelfClosing ` to control whether a space is used before the slash.
105111
106112Not used in the SVG space.
107113
@@ -110,55 +116,56 @@ Not used in the SVG space.
110116Close SVG elements without any content with slash (` / ` ) on the opening tag
111117instead of an end tag: ` <circle /> ` instead of ` <circle></circle> ` (` boolean ` ,
112118default: ` false ` ).
119+ See ` tightSelfClosing ` to control whether a space is used before the slash.
113120
114121Not used in the HTML space.
115122
116123###### ` options.tightSelfClosing `
117124
118- Do not use an extra space when closing self-closing elements: ` <img/> `
119- instead of ` <img /> ` (` boolean ` , default: ` false ` ). ** Note ** : Only used
120- if ` closeSelfClosing: true ` or ` closeEmptyElements: true ` .
125+ Do not use an extra space when closing self-closing elements: ` <img/> ` instead
126+ of ` <img /> ` (` boolean ` , default: ` false ` ).
127+ ** Note ** : Only used if ` closeSelfClosing: true ` or ` closeEmptyElements: true ` .
121128
122129###### ` options.tightCommaSeparatedLists `
123130
124- Join known comma-separated attribute values with just a comma (` , ` ),
125- instead of padding them on the right as well (` ,· ` , where ` · ` represents a
126- space) (` boolean ` , default: ` false ` ).
131+ Join known comma-separated attribute values with just a comma (` , ` ), instead of
132+ padding them on the right as well (` ,· ` , where ` · ` represents a space)
133+ (` boolean ` , default: ` false ` ).
127134
128135###### ` options.tightAttributes `
129136
130- Join attributes together, without white-space, if possible:
131- ` class="a b" title="c d"` is stringified as ` class="a b"title="c d" `
132- instead to save bytes (` boolean ` , default: ` false ` ). ** Note ** : creates
133- invalid (but working) markup.
137+ Join attributes together, without white-space, if possible: `class="a b"
138+ title="c d"` is stringified as ` class="a b"title="c d"` instead to save bytes
139+ (` boolean ` , default: ` false ` ).
140+ ** Note ** : creates invalid (but working) markup.
134141
135142Not used in the SVG space.
136143
137144###### ` options.tightDoctype `
138145
139146Drop unneeded spaces in doctypes: ` <!doctypehtml> ` instead of ` <!doctype html> `
140- to save bytes (` boolean ` , default: ` false ` ). ** Note ** : creates
141- invalid (but working) markup.
147+ to save bytes (` boolean ` , default: ` false ` ).
148+ ** Note ** : creates invalid (but working) markup.
142149
143150###### ` options.allowParseErrors `
144151
145- Do not encode characters which trigger parse errors (even though they
146- work), to save bytes (` boolean ` , default: ` false ` ). ** Note ** : creates
147- invalid (but working) markup.
152+ Do not encode characters which cause parse errors (even though they work), to
153+ save bytes (` boolean ` , default: ` false ` ).
154+ ** Note ** : creates invalid (but working) markup.
148155
149156Not used in the SVG space.
150157
151158###### ` options.allowDangerousCharacters `
152159
153- Do not encode some characters which cause XSS vulnerabilities in older
154- browsers (` boolean ` , default: ` false ` ). ** Note ** : Only set this if you
155- completely trust the content.
160+ Do not encode some characters which cause XSS vulnerabilities in older browsers
161+ (` boolean ` , default: ` false ` ).
162+ ** Note ** : Only set this if you completely trust the content.
156163
157164###### ` options.allowDangerousHTML `
158165
159- Allow ` raw ` nodes and insert them as raw HTML. When falsey, encodes
160- ` raw ` nodes (` boolean ` , default: ` false ` ). ** Note ** : Only set this if
161- you completely trust the content.
166+ Allow ` raw ` nodes and insert them as raw HTML.
167+ When falsey, encodes ` raw ` nodes (` boolean ` , default: ` false ` ).
168+ ** Note ** : Only set this if you completely trust the content.
162169
163170## Related
164171
@@ -169,11 +176,13 @@ you completely trust the content.
169176
170177## Contribute
171178
172- See [ ` contributing.md ` in ` syntax-tree/hast ` ] [ contributing ] for ways to get
179+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
173180started.
181+ See [ ` support.md ` ] [ support ] for ways to get help.
174182
175- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
176- repository, organisation, or community you agree to abide by its terms.
183+ This project has a [ Code of Conduct] [ coc ] .
184+ By interacting with this repository, organisation, or community you agree to
185+ abide by its terms.
177186
178187## License
179188
@@ -193,24 +202,42 @@ repository, organisation, or community you agree to abide by its terms.
193202
194203[ downloads ] : https://www.npmjs.com/package/hast-util-to-html
195204
205+ [ size-badge ] : https://img.shields.io/bundlephobia/minzip/hast-util-to-html.svg
206+
207+ [ size ] : https://bundlephobia.com/result?p=hast-util-to-html
208+
209+ [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
210+
211+ [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
212+
213+ [ collective ] : https://opencollective.com/unified
214+
196215[ chat-badge ] : https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
197216
198- [ chat ] : https://spectrum.chat/unified/rehype
217+ [ chat ] : https://spectrum.chat/unified/syntax-tree
199218
200219[ npm ] : https://docs.npmjs.com/cli/install
201220
202221[ license ] : license
203222
204223[ author ] : https://wooorm.com
205224
206- [ hast ] : https://github.com/syntax-tree/hast
225+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
226+
227+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
228+
229+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
207230
208231[ html-void-elements ] : https://github.com/wooorm/html-void-elements
209232
210233[ stringify-entities ] : https://github.com/wooorm/stringify-entities
211234
212235[ hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
213236
214- [ contributing ] : https://github.com/syntax-tree/hast/blob/master/contributing.md
237+ [ tree ] : https://github.com/syntax-tree/unist#tree
238+
239+ [ root ] : https://github.com/syntax-tree/unist#root
240+
241+ [ hast ] : https://github.com/syntax-tree/hast
215242
216- [ coc ] : https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
243+ [ element ] : https://github.com/syntax-tree/hast#element
0 commit comments