1
1
# hast-util-to-xast
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] [ ] (HTML) utility to transform to [ xast] [ ] (XML).
8
+ [ hast] [ github-hast ] (HTML) utility to transform to [ xast] [ github-xast ] (XML).
12
9
13
10
## Contents
14
11
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
- * [ ` toXast(tree[, options]) ` ] ( #toxasttree-options )
21
- * [ ` Options ` ] ( #options )
22
- * [ ` Space ` ] ( #space-1 )
23
- * [ Types] ( #types )
24
- * [ Compatibility] ( #compatibility )
25
- * [ Security] ( #security )
26
- * [ Related] ( #related )
27
- * [ Contribute] ( #contribute )
28
- * [ License] ( #license )
12
+ * [ What is this?] ( #what-is-this )
13
+ * [ When should I use this?] ( #when-should-i-use-this )
14
+ * [ Install] ( #install )
15
+ * [ Use] ( #use )
16
+ * [ API] ( #api )
17
+ * [ ` toXast(tree[, options]) ` ] ( #toxasttree-options )
18
+ * [ ` Options ` ] ( #options )
19
+ * [ ` Space ` ] ( #space-1 )
20
+ * [ Types] ( #types )
21
+ * [ Compatibility] ( #compatibility )
22
+ * [ Security] ( #security )
23
+ * [ Related] ( #related )
24
+ * [ Contribute] ( #contribute )
25
+ * [ License] ( #license )
29
26
30
27
## What is this?
31
28
32
- This package is a utility that takes a [ hast] [ ] (HTML) syntax tree as input and
33
- turns it into a [ xast] [ ] (XML) syntax tree.
29
+ This package is a utility that takes a
30
+ [ hast] [ github-hast ] (HTML)
31
+ syntax tree as input and turns it into a
32
+ [ xast] [ github-xast ] (XML)
33
+ syntax tree.
34
34
This package also supports embedded MDX nodes.
35
35
36
36
## When should I use this?
@@ -41,13 +41,15 @@ One example of this is for EPUB (digital books).
41
41
42
42
There is no inverse of this utility, because not all XML is HTML.
43
43
44
- A similar package, [ ` hast-util-to-estree ` ] [ hast-util-to-estree ] , can turn
45
- hast into estree (JavaScript) as JSX, which has some similarities to XML.
44
+ A similar package, [ ` hast-util-to-estree ` ] [ github-hast-util-to-estree ] ,
45
+ can turn hast into estree (JavaScript) as JSX,
46
+ which has some similarities to XML.
46
47
47
48
## Install
48
49
49
- This package is [ ESM only] [ esm ] .
50
- In Node.js (version 16+), install with [ npm] [ ] :
50
+ This package is [ ESM only] [ github-gist-esm ] .
51
+ In Node.js (version 16+), install with
52
+ [ npm] [ npmjs-install ] :
51
53
52
54
``` sh
53
55
npm install hast-util-to-xast
@@ -56,14 +58,14 @@ npm install hast-util-to-xast
56
58
In Deno with [ ` esm.sh ` ] [ esmsh ] :
57
59
58
60
``` js
59
- import {toXast } from " https://esm.sh/hast-util-to-xast@3"
61
+ import {toXast } from ' https://esm.sh/hast-util-to-xast@3'
60
62
```
61
63
62
64
In browsers with [ ` esm.sh ` ] [ esmsh ] :
63
65
64
66
``` html
65
67
<script type =" module" >
66
- import {toXast } from " https://esm.sh/hast-util-to-xast@3?bundle"
68
+ import {toXast } from ' https://esm.sh/hast-util-to-xast@3?bundle'
67
69
</script >
68
70
```
69
71
@@ -110,18 +112,18 @@ There is no default export.
110
112
111
113
### ` toXast(tree[, options]) `
112
114
113
- Turn a [ hast] [ ] tree into a [ xast] [ ] tree.
115
+ Turn a [ hast] [ github-hast ] tree into a [ xast] [ github-xast ] tree.
114
116
115
117
###### Parameters
116
118
117
- * ` tree ` ([ ` HastNode ` ] [ hast-node ] )
118
- — hast tree to transform
119
- * ` options ` ([ ` Options ` ] [ api-options ] , optional)
120
- — configuration
119
+ * ` tree ` ([ ` HastNode ` ] [ github- hast-nodes ] )
120
+ — hast tree to transform
121
+ * ` options ` ([ ` Options ` ] [ api-options ] , optional)
122
+ — configuration
121
123
122
124
###### Returns
123
125
124
- xast tree ([ ` XastNode ` ] [ xast-node ] ).
126
+ xast tree ([ ` XastNode ` ] [ github- xast-nodes ] ).
125
127
126
128
### ` Options `
127
129
@@ -168,94 +170,86 @@ compatible with Node.js 16.
168
170
## Security
169
171
170
172
Both HTML and XML can be dangerous languages: don’t trust user-provided data.
171
- Use [ ` hast -util -santize ` ][hast-util-sanitize] to make the hast tree safe before
172
- using this utility.
173
+ Use [ ` hast -util -santize ` ][github- hast-util-sanitize]
174
+ to make the hast tree safe before using this utility.
173
175
174
176
## Related
175
177
176
- * [ ` hastscript ` ](https://github.com/syntax-tree/hastscript)
177
- — create ** [hast][]** (HTML or SVG) trees
178
- * [ ` xastscript ` ](https://github.com/syntax-tree/xastscript)
179
- — create ** [xast][]** (XML) trees
180
- * [ ` xast -util -to -xml ` ](https://github.com/syntax-tree/xast-util-to-xml)
181
- — serialize as XML
178
+ * [ ` hastscript ` ](https://github.com/syntax-tree/hastscript)
179
+ — create [hast][github-hast] (HTML or SVG) trees
180
+ * [ ` xastscript ` ](https://github.com/syntax-tree/xastscript)
181
+ — create [xast][github-xast] (XML) trees
182
+ * [ ` xast -util -to -xml ` ](https://github.com/syntax-tree/xast-util-to-xml)
183
+ — serialize as XML
182
184
183
185
## Contribute
184
186
185
- See [ ` contributing .md ` ][contributing] in [ ` syntax -tree /.github ` ][health] for
186
- ways to get started.
187
- See [ ` support .md ` ][support] for ways to get help.
187
+ See [ ` contributing .md ` ][health-contributing]
188
+ in
189
+ [ ` syntax -tree /.github ` ][health]
190
+ for ways to get started.
191
+ See [ ` support .md ` ][health-support] for ways to get help.
188
192
189
- This project has a [code of conduct][coc].
193
+ This project has a [code of conduct][health- coc].
190
194
By interacting with this repository, organization, or community you agree to
191
195
abide by its terms.
192
196
193
197
## License
194
198
195
- [MIT][license] © [Titus Wormer][author ]
199
+ [MIT][file- license] © [Titus Wormer][wooorm ]
196
200
197
201
<!-- Definitions -->
198
202
199
- [build-badge]: https://github.com/syntax-tree/hast-util-to-xast/workflows/main/badge.svg
200
-
201
- [build]: https://github.com/syntax-tree/hast-util-to-xast/actions
202
-
203
- [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-xast.svg
204
-
205
- [coverage]: https://codecov.io/github/syntax-tree/hast-util-to-xast
206
-
207
- [downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-xast.svg
203
+ [api-options]: #options
208
204
209
- [downloads ]: https://www.npmjs.com/package/hast-util-to-xast
205
+ [api-space ]: #space-1
210
206
211
- [size-badge ]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-to-xast
207
+ [api-to-xast ]: #toxasttree-options
212
208
213
- [size ]: https://bundlejs .com/?q= hast-util-to-xast
209
+ [badge-build-image ]: https://github .com/syntax-tree/ hast-util-to-xast/workflows/main/badge.svg
214
210
215
- [sponsors- badge]: https://opencollective .com/unified/sponsors/badge.svg
211
+ [badge-build-url ]: https://github .com/syntax-tree/hast-util-to-xast/actions
216
212
217
- [backers- badge]: https://opencollective.com/unified/backers/badge .svg
213
+ [badge-coverage-image ]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-xast .svg
218
214
219
- [collective ]: https://opencollective.com/unified
215
+ [badge-coverage-url ]: https://codecov.io/github/syntax-tree/hast-util-to-xast
220
216
221
- [chat- badge]: https://img.shields.io/badge/chat-discussions-success .svg
217
+ [badge-downloads-image ]: https://img.shields.io/npm/dm/hast-util-to-xast .svg
222
218
223
- [chat ]: https://github. com/syntax-tree/unist/discussions
219
+ [badge-downloads-url ]: https://www.npmjs. com/package/hast-util-to-xast
224
220
225
- [npm ]: https://docs.npmjs.com/cli/install
221
+ [badge-size-image ]: https://img.shields.io/bundlejs/size/hast-util-to-xast
226
222
227
- [esm ]: https://gist.github. com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
223
+ [badge-size-url ]: https://bundlejs. com/?q=hast-util-to-xast
228
224
229
225
[esmsh]: https://esm.sh
230
226
231
- [typescript ]: https://www.typescriptlang.org
227
+ [file-license ]: license
232
228
233
- [license ]: license
229
+ [github-gist-esm ]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
234
230
235
- [author ]: https://wooorm .com
231
+ [github-hast ]: https://github .com/syntax-tree/hast
236
232
237
- [health]: https://github.com/syntax-tree/.github
238
-
239
- [contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
233
+ [github-hast-nodes]: https://github.com/syntax-tree/hast#nodes
240
234
241
- [support ]: https://github.com/syntax-tree/.github/blob/main/support.md
235
+ [github-hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
242
236
243
- [coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
237
+ [github-hast-util-to-estree ]: https://github.com/syntax-tree/hast-util-to-estree
244
238
245
- [hast ]: https://github.com/syntax-tree/hast
239
+ [github-xast ]: https://github.com/syntax-tree/xast
246
240
247
- [hast-node ]: https://github.com/syntax-tree/hast #nodes
241
+ [github-xast-nodes ]: https://github.com/syntax-tree/xast #nodes
248
242
249
- [hast-util-sanitize ]: https://github.com/syntax-tree/hast-util-sanitize
243
+ [health ]: https://github.com/syntax-tree/.github
250
244
251
- [hast-util-to-estree ]: https://github.com/syntax-tree/hast-util-to-estree
245
+ [health-coc ]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
252
246
253
- [xast ]: https://github.com/syntax-tree/xast
247
+ [health-contributing ]: https://github.com/syntax-tree/.github/blob/main/contributing.md
254
248
255
- [xast-node ]: https://github.com/syntax-tree/xast#nodes
249
+ [health-support ]: https://github.com/syntax-tree/.github/blob/main/support.md
256
250
257
- [api-to-xast ]: #toxasttree-options
251
+ [npmjs-install ]: https://docs.npmjs.com/cli/install
258
252
259
- [api-options ]: #options
253
+ [typescript ]: https://www.typescriptlang.org
260
254
261
- [api-space ]: #space-1
255
+ [wooorm ]: https://wooorm.com
0 commit comments