8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- ** [ xast] [ ] ** utility to serialize to XML.
11
+ [ xast] [ ] utility to serialize as XML.
12
12
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.
14
31
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?
17
33
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] [ ] :
19
54
20
55
``` sh
21
56
npm install xast-util-to-xml
22
57
```
23
58
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
+
24
73
## Use
25
74
26
75
``` js
@@ -64,12 +113,16 @@ Yields:
64
113
65
114
## API
66
115
67
- This package exports the following identifiers: ` toXml ` .
116
+ This package exports the identifier ` toXml ` .
68
117
There is no default export.
69
118
70
119
### ` toXml(tree[, options]) `
71
120
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).
73
126
74
127
###### ` options.quote `
75
128
@@ -95,7 +148,20 @@ instead of `<circle />` (`boolean`, default: `false`).
95
148
96
149
Allow ` raw ` nodes and insert them as raw XML.
97
150
When 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.
99
165
100
166
## Security
101
167
@@ -112,8 +178,8 @@ XML can be a dangerous language: don’t trust user-provided data.
112
178
113
179
## Contribute
114
180
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.
117
183
See [ ` support.md ` ] [ support ] for ways to get help.
118
184
119
185
This project has a [ code of conduct] [ coc ] .
@@ -154,16 +220,28 @@ abide by its terms.
154
220
155
221
[ npm ] : https://docs.npmjs.com/cli/install
156
222
223
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
224
+
225
+ [ esmsh ] : https://esm.sh
226
+
227
+ [ typescript ] : https://www.typescriptlang.org
228
+
157
229
[ license ] : license
158
230
159
231
[ author ] : https://wooorm.com
160
232
161
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
233
+ [ health ] : https://github.com/syntax-tree/.github
162
234
163
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
235
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
164
236
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
166
238
167
- [ tree ] : https://github.com/syntax-tree/unist#tree
239
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
168
240
169
241
[ 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