8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** xast** ] [ xast ] utility to get the plain text value of a [ * node* ] [ node ] .
11
+ [ xast] [ ] utility to get the plain- text value of a node.
12
12
13
- This is like the DOMs ` Node#textContent ` getter but there are some deviations.
14
- The resulting text is returned.
13
+ ## Contents
15
14
16
- ## Install
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
+ * [ ` toString(node) ` ] ( #tostringnode )
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 takes a [ xast] [ ] node and gets its plain-text
31
+ value.
32
+ This is like the DOMs ` Node#textContent ` getter but there are some small
33
+ deviations.
17
34
18
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
19
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
35
+ ## When should I use this?
36
+
37
+ This is a small utility that is useful when you want a plain-text version of a
38
+ node when working with xast (XML).
39
+
40
+ ## Install
20
41
21
- [ npm] [ ] :
42
+ This package is [ ESM only] [ esm ] .
43
+ In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [ npm] [ ] :
22
44
23
45
``` sh
24
46
npm install xast-util-to-string
25
47
```
26
48
49
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
50
+
51
+ ``` js
52
+ import {toString } from " https://esm.sh/xast-util-to-string@2"
53
+ ```
54
+
55
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
56
+
57
+ ``` html
58
+ <script type =" module" >
59
+ import {toString } from " https://esm.sh/xast-util-to-string@2?bundle"
60
+ </script >
61
+ ```
62
+
27
63
## Use
28
64
29
65
``` js
@@ -53,12 +89,12 @@ A Christmas CarolCharles Dickens
53
89
54
90
## API
55
91
56
- This package exports the following identifiers: ` toString ` .
92
+ This package exports the identifier ` toString ` .
57
93
There is no default export.
58
94
59
95
### ` toString(node) `
60
96
61
- Utility to get the plain text value of a [ * node* ] [ node ] .
97
+ Get the plain text value of a node.
62
98
If the node has a ` value ` field ([ * cdata* ] [ cdata ] , [ * comment* ] [ comment ] ,
63
99
[ * doctype* ] [ doctype ] , [ * instruction* ] [ instruction ] , or [ * text* ] [ text ] ), returns
64
100
it.
@@ -67,7 +103,19 @@ recurses into it to concatenate all [*text*][text]s.
67
103
68
104
###### Returns
69
105
70
- ` string ` — Serialized ` node ` .
106
+ Serialized ` node ` (` string ` ).
107
+
108
+ ## Types
109
+
110
+ This package is fully typed with [ TypeScript] [ ] .
111
+ It exports no additional types.
112
+
113
+ ## Compatibility
114
+
115
+ Projects maintained by the unified collective are compatible with all maintained
116
+ versions of Node.js.
117
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
118
+ Our projects sometimes work with older versions, but this is not guaranteed.
71
119
72
120
## Security
73
121
@@ -78,19 +126,19 @@ for [cross-site scripting (XSS)][xss] attacks.
78
126
79
127
* [ ` xast-util-to-xml ` ] ( https://github.com/syntax-tree/xast-util-to-xml )
80
128
— serialize xast to XML
81
- * [ ` hast-util-to-string ` ] ( https://github.com/rehypejs/rehype-minify/tree/HEAD /packages/hast-util-to-string )
129
+ * [ ` hast-util-to-string ` ] ( https://github.com/rehypejs/rehype-minify/tree/main /packages/hast-util-to-string )
82
130
— get the plain-text value (` textContent ` )
83
131
* [ ` hast-util-to-text ` ] ( https://github.com/syntax-tree/hast-util-to-text )
84
132
— get the plain-text value (` innerText ` )
85
133
* [ ` hast-util-from-text ` ] ( https://github.com/syntax-tree/hast-util-from-text )
86
134
— set the plain-text value (` innerText ` )
87
- * [ ` hast-util-from-string ` ] ( https://github.com/rehypejs/rehype-minify/tree/HEAD /packages/hast-util-from-string )
135
+ * [ ` hast-util-from-string ` ] ( https://github.com/rehypejs/rehype-minify/tree/main /packages/hast-util-from-string )
88
136
— set the plain-text value (` textContent ` )
89
137
90
138
## Contribute
91
139
92
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
93
- started.
140
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
141
+ ways to get started.
94
142
See [ ` support.md ` ] [ support ] for ways to get help.
95
143
96
144
This project has a [ code of conduct] [ coc ] .
@@ -131,19 +179,25 @@ abide by its terms.
131
179
132
180
[ npm ] : https://docs.npmjs.com/cli/install
133
181
182
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
183
+
184
+ [ esmsh ] : https://esm.sh
185
+
186
+ [ typescript ] : https://www.typescriptlang.org
187
+
134
188
[ license ] : license
135
189
136
190
[ author ] : https://wooorm.com
137
191
138
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
192
+ [ health ] : https://github.com/syntax-tree/.github
139
193
140
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
194
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
141
195
142
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct .md
196
+ [ support ] : https://github.com/syntax-tree/.github/blob/main/support .md
143
197
144
- [ xast ] : https://github.com/syntax-tree/xast
198
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
145
199
146
- [ node ] : https://github.com/syntax-tree/xast#nodes
200
+ [ xast ] : https://github.com/syntax-tree/xast
147
201
148
202
[ root ] : https://github.com/syntax-tree/xast#root
149
203
0 commit comments