17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` toString(node[, options]) ` ] ( #tostringnode-options )
20
+ * [ ` toString(value[, options]) ` ] ( #tostringvalue-options )
21
+ * [ ` Options ` ] ( #options )
21
22
* [ Types] ( #types )
22
23
* [ Compatibility] ( #compatibility )
23
24
* [ Security] ( #security )
@@ -43,7 +44,7 @@ Similar packages, [`hast-util-to-string`][hast-util-to-string] and
43
44
## Install
44
45
45
46
This package is [ ESM only] [ esm ] .
46
- In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
47
+ In Node.js (version 14.14+ and 16.0+), install with [ npm] [ ] :
47
48
48
49
``` sh
49
50
npm install mdast-util-to-string
@@ -77,33 +78,46 @@ console.log(toString(tree)) // => 'Some emphasis, importance, and code.'
77
78
78
79
## API
79
80
80
- This package exports the identifier ` toString ` .
81
+ This package exports the identifier [ ` toString ` ] [ api-tostring ] .
81
82
There is no default export.
82
83
83
- ### ` toString(node [, options]) `
84
+ ### ` toString(value [, options]) `
84
85
85
- Get the text content of a [ node] [ ] or list of nodes.
86
- Prefers the node’s plain-text fields, otherwise serializes its children, and if
87
- the given value is an array, serialize the nodes in it.
86
+ Get the text content of a node or list of nodes.
88
87
89
- ##### ` options `
88
+ Prefers the node’s plain-text fields, otherwise serializes its children,
89
+ and if the given value is an array, serialize the nodes in it.
90
90
91
- Configuration (optional).
91
+ ###### Parameters
92
92
93
- ###### ` options.includeImageAlt `
93
+ * ` value ` (` unknown ` )
94
+ — thing to serialize, typically [ ` Node ` ] [ node ]
95
+ * ` options ` ([ ` Options ` ] [ api-options ] , optional)
96
+ — configuration
94
97
95
- Whether to use ` alt ` (` boolean ` , default: ` true ` ).
98
+ ###### Returns
99
+
100
+ Serialized ` value ` (` string ` ).
101
+
102
+ ### ` Options `
103
+
104
+ Configuration (TypeScript type).
105
+
106
+ ###### Fields
107
+
108
+ * ` includeImageAlt ` (` boolean ` , default: ` true ` )
109
+ — whether to use ` alt ` for ` image ` s
96
110
97
111
## Types
98
112
99
113
This package is fully typed with [ TypeScript] [ ] .
100
- It exports the type ` Options ` .
114
+ It exports the additional type [ ` Options ` ] [ api-options ] .
101
115
102
116
## Compatibility
103
117
104
118
Projects maintained by the unified collective are compatible with all maintained
105
119
versions of Node.js.
106
- As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
120
+ As of now, that is Node.js 14.14+ and 16.0+.
107
121
Our projects sometimes work with older versions, but this is not guaranteed.
108
122
109
123
## Security
@@ -194,3 +208,7 @@ abide by its terms.
194
208
[ node ] : https://github.com/syntax-tree/mdast#nodes
195
209
196
210
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
211
+
212
+ [ api-tostring ] : #tostringvalue-options
213
+
214
+ [ api-options ] : #options
0 commit comments