88[ ![ Backers] [ backers-badge ]] [ collective ]
99[ ![ Chat] [ chat-badge ]] [ chat ]
1010
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.
1212
13- This is like the DOMs ` Node#textContent ` getter but there are some deviations.
14- The resulting text is returned.
13+ ## Contents
1514
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.
1734
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
2041
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] [ ] :
2244
2345``` sh
2446npm install xast-util-to-string
2547```
2648
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+
2763## Use
2864
2965``` js
@@ -53,12 +89,12 @@ A Christmas CarolCharles Dickens
5389
5490## API
5591
56- This package exports the following identifiers: ` toString ` .
92+ This package exports the identifier ` toString ` .
5793There is no default export.
5894
5995### ` toString(node) `
6096
61- Utility to get the plain text value of a [ * node* ] [ node ] .
97+ Get the plain text value of a node.
6298If the node has a ` value ` field ([ * cdata* ] [ cdata ] , [ * comment* ] [ comment ] ,
6399[ * doctype* ] [ doctype ] , [ * instruction* ] [ instruction ] , or [ * text* ] [ text ] ), returns
64100it.
@@ -67,7 +103,19 @@ recurses into it to concatenate all [*text*][text]s.
67103
68104###### Returns
69105
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.
71119
72120## Security
73121
@@ -78,19 +126,19 @@ for [cross-site scripting (XSS)][xss] attacks.
78126
79127* [ ` xast-util-to-xml ` ] ( https://github.com/syntax-tree/xast-util-to-xml )
80128 — 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 )
82130 — get the plain-text value (` textContent ` )
83131* [ ` hast-util-to-text ` ] ( https://github.com/syntax-tree/hast-util-to-text )
84132 — get the plain-text value (` innerText ` )
85133* [ ` hast-util-from-text ` ] ( https://github.com/syntax-tree/hast-util-from-text )
86134 — 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 )
88136 — set the plain-text value (` textContent ` )
89137
90138## Contribute
91139
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.
94142See [ ` support.md ` ] [ support ] for ways to get help.
95143
96144This project has a [ code of conduct] [ coc ] .
@@ -131,19 +179,25 @@ abide by its terms.
131179
132180[ npm ] : https://docs.npmjs.com/cli/install
133181
182+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
183+
184+ [ esmsh ] : https://esm.sh
185+
186+ [ typescript ] : https://www.typescriptlang.org
187+
134188[ license ] : license
135189
136190[ author ] : https://wooorm.com
137191
138- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
192+ [ health ] : https://github.com/syntax-tree/.github
139193
140- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
194+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
141195
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
143197
144- [ xast ] : https://github.com/syntax-tree/xast
198+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
145199
146- [ node ] : https://github.com/syntax-tree/xast#nodes
200+ [ xast ] : https://github.com/syntax-tree/xast
147201
148202[ root ] : https://github.com/syntax-tree/xast#root
149203
0 commit comments