Skip to content

Commit 1d7671c

Browse files
committed
Add improved docs
1 parent 735093b commit 1d7671c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: lib/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const search = /\r?\n|\r/g
2525
/**
2626
* Parse a string of XML to a xast tree.
2727
*
28-
* @param {string | Uint8Array} doc
28+
* @param {string | Uint8Array} value
2929
* Serialized XML.
3030
* @returns {Root}
3131
* xast root.
3232
*/
33-
export function fromXml(doc) {
33+
export function fromXml(value) {
3434
// @ts-expect-error `strictEntities` is most definitely fine.
3535
const parser = new Parser(true, {position: true, strictEntities: true})
3636
/** @type {[Root, ...Array<Node>]} */
@@ -50,7 +50,7 @@ export function fromXml(doc) {
5050
parser.onerror = onerror
5151

5252
// @ts-expect-error Buffers are most definitely fine.
53-
parser.write(doc).close()
53+
parser.write(value).close()
5454

5555
return stack[0]
5656

Diff for: readme.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ It turns xast into XML.
4444
## Install
4545

4646
This package is [ESM only][esm].
47-
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
47+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4848

4949
```sh
5050
npm install xast-util-from-xml
@@ -129,22 +129,21 @@ console.log(tree)
129129

130130
## API
131131

132-
This package exports the identifier `fromXml`.
132+
This package exports the identifier [`fromXml`][fromxml].
133133
There is no default export.
134134

135135
### `fromXml(value)`
136136

137-
Turn XML into a syntax tree.
137+
Parse a string of XML to a xast tree.
138138

139139
##### Parameters
140140

141-
###### `value`
142-
143-
Value to parse (`string` or `Buffer` in UTF-8).
141+
* `value` (`string` or `Buffer` in UTF-8).
142+
— serialized XML
144143

145144
##### Returns
146145

147-
[`Root`][root].
146+
xast root ([`Root`][root]).
148147

149148
## Types
150149

@@ -155,7 +154,7 @@ It exports no additional types.
155154

156155
Projects maintained by the unified collective are compatible with all maintained
157156
versions of Node.js.
158-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
157+
As of now, that is Node.js 14.14+ and 16.0+.
159158
Our projects sometimes work with older versions, but this is not guaranteed.
160159

161160
## Security
@@ -240,3 +239,5 @@ abide by its terms.
240239
[sax]: https://github.com/isaacs/sax-js
241240

242241
[xast-util-to-xml]: https://github.com/syntax-tree/xast-util-to-xml
242+
243+
[fromxml]: #fromxmlvalue

0 commit comments

Comments
 (0)