88[ ![ Backers] [ backers-badge ]] [ collective ]
99[ ![ Chat] [ chat-badge ]] [ chat ]
1010
11- ** [ xast] [ ] ** utility to serialize to XML.
11+ [ xast] [ ] utility to serialize as XML.
1212
13- ## Install
13+ ## Contents
14+
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+ * [ ` toXml(tree[, options]) ` ] ( #toxmltree-options )
21+ * [ Types] ( #types )
22+ * [ Compatibility] ( #compatibility )
23+ * [ Security] ( #security )
24+ * [ Related] ( #related )
25+ * [ Contribute] ( #contribute )
26+ * [ License] ( #license )
27+
28+ ## What is this?
29+
30+ This package is a utility that turns a xast tree into a string of XML.
1431
15- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
16- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
32+ ## When should I use this?
1733
18- [ npm] [ ] :
34+ You can use this utility when you want to get the serialized XML that is
35+ represented by the syntax tree, either because you’re done with the syntax tree,
36+ or because you’re integrating with another tool that does not support syntax
37+ trees.
38+
39+ This utility has options to configure how the XML is serialized.
40+ These options help when building tools that make output pretty (such as
41+ formatters) or ugly (such as minifiers).
42+
43+ The utility [ ` xast-util-from-xml ` ] [ xast-util-from-xml ] does the inverse of this
44+ utility.
45+ It turns XML into xast.
46+
47+ The utility [ ` hast-util-to-html ` ] [ hast-util-to-html ] does the same as this
48+ utility but for HTML: it turns [ hast] [ ] into HTML.
49+
50+ ## Install
51+
52+ This package is [ ESM only] [ esm ] .
53+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
1954
2055``` sh
2156npm install xast-util-to-xml
2257```
2358
59+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
60+
61+ ``` js
62+ import {toXml } from ' https://esm.sh/xast-util-to-xml@3'
63+ ```
64+
65+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
66+
67+ ``` html
68+ <script type =" module" >
69+ import {toXml } from ' https://esm.sh/xast-util-to-xml@3?bundle'
70+ </script >
71+ ```
72+
2473## Use
2574
2675``` js
@@ -64,12 +113,16 @@ Yields:
64113
65114## API
66115
67- This package exports the following identifiers: ` toXml ` .
116+ This package exports the identifier ` toXml ` .
68117There is no default export.
69118
70119### ` toXml(tree[, options]) `
71120
72- Serialize the given ** [ xast] [ ] ** * [ tree] [ ] * (or list of nodes).
121+ Serialize the given [ xast] [ ] node (or list of nodes).
122+
123+ ##### ` options `
124+
125+ Configuration (optional).
73126
74127###### ` options.quote `
75128
@@ -95,7 +148,20 @@ instead of `<circle />` (`boolean`, default: `false`).
95148
96149Allow ` raw ` nodes and insert them as raw XML.
97150When falsey, encodes ` raw ` nodes (` boolean ` , default: ` false ` ).
98- ** Note** : Only set this if you completely trust the content.
151+
152+ > ☢️ ** Danger** : only set this if you completely trust the content.
153+
154+ ## Types
155+
156+ This package is fully typed with [ TypeScript] [ ] .
157+ It exports the additional type ` Options ` .
158+
159+ ## Compatibility
160+
161+ Projects maintained by the unified collective are compatible with all maintained
162+ versions of Node.js.
163+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
164+ Our projects sometimes work with older versions, but this is not guaranteed.
99165
100166## Security
101167
@@ -112,8 +178,8 @@ XML can be a dangerous language: don’t trust user-provided data.
112178
113179## Contribute
114180
115- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
116- started.
181+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
182+ ways to get started.
117183See [ ` support.md ` ] [ support ] for ways to get help.
118184
119185This project has a [ code of conduct] [ coc ] .
@@ -154,16 +220,28 @@ abide by its terms.
154220
155221[ npm ] : https://docs.npmjs.com/cli/install
156222
223+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
224+
225+ [ esmsh ] : https://esm.sh
226+
227+ [ typescript ] : https://www.typescriptlang.org
228+
157229[ license ] : license
158230
159231[ author ] : https://wooorm.com
160232
161- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
233+ [ health ] : https://github.com/syntax-tree/.github
162234
163- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
235+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
164236
165- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct .md
237+ [ support ] : https://github.com/syntax-tree/.github/blob/main/support .md
166238
167- [ tree ] : https://github.com/syntax-tree/unist#tree
239+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
168240
169241[ xast ] : https://github.com/syntax-tree/xast
242+
243+ [ hast ] : https://github.com/syntax-tree/hast
244+
245+ [ xast-util-from-xml ] : https://github.com/syntax-tree/xast-util-from-xml
246+
247+ [ hast-util-to-html ] : https://github.com/syntax-tree/hast-util-to-html
0 commit comments