Skip to content

Commit 4f54017

Browse files
committed
Add improved docs
1 parent 92a834a commit 4f54017

File tree

1 file changed

+61
-24
lines changed

1 file changed

+61
-24
lines changed

readme.md

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,42 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**mdast**][mdast] utility to make trees compact: collapse adjacent text nodes
12-
and blockquotes.
11+
[mdast][] utility to make trees compact by collapsing adjacent text nodes and
12+
blockquotes.
1313

14-
## Install
14+
## What is this?
15+
16+
This package is a utility that lets you make a tree, after changes, more similar
17+
to how it would be parsed.
1518

16-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
17-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
19+
## When should I use this?
1820

19-
[npm][]:
21+
Probably never!
22+
You should try and keep your trees clean yourself.
23+
24+
## Install
25+
26+
This package is [ESM only][esm].
27+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
2028

2129
```sh
2230
npm install mdast-util-compact
2331
```
2432

33+
In Deno with [`esm.sh`][esmsh]:
34+
35+
```js
36+
import {compact} from 'https://esm.sh/mdast-util-compact@4'
37+
```
38+
39+
In browsers with [`esm.sh`][esmsh]:
40+
41+
```html
42+
<script type="module">
43+
import {compact} from 'https://esm.sh/mdast-util-compact@4?bundle'
44+
</script>
45+
```
46+
2547
## Use
2648

2749
```js
@@ -46,24 +68,35 @@ Yields:
4668

4769
## API
4870

49-
This package exports the following identifiers: `compact`.
71+
This package exports the identifier `compact`.
5072
There is no default export.
5173

5274
### `compact(tree)`
5375

54-
Walk the [tree][] and collapse nodes.
55-
Combines adjacent [text][]s and collapses [blockquote][]s.
56-
76+
Collapse nodes in `tree` ([`Node`][node]).
77+
Combines adjacent texts and collapses blockquotes.
5778
Handles [positional information][position-information] properly.
5879

5980
###### Returns
6081

61-
The given `tree`.
82+
The given `tree` ([`Node`][node]).
83+
84+
## Types
85+
86+
This package is fully typed with [TypeScript][].
87+
There are no additional types exported.
88+
89+
## Compatibility
90+
91+
Projects maintained by the unified collective are compatible with all maintained
92+
versions of Node.js.
93+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
94+
Our projects sometimes work with older versions, but this is not guaranteed.
6295

6396
## Security
6497

65-
Use of `mdast-util-compact` does not involve [**hast**][hast] or user content
66-
so there are no openings for [cross-site scripting (XSS)][xss] attacks.
98+
Use of `mdast-util-compact` does not involve **[hast][]** or user content so
99+
there are no openings for [cross-site scripting (XSS)][xss] attacks.
67100

68101
## Related
69102

@@ -72,8 +105,8 @@ so there are no openings for [cross-site scripting (XSS)][xss] attacks.
72105

73106
## Contribute
74107

75-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
76-
started.
108+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
109+
ways to get started.
77110
See [`support.md`][support] for ways to get help.
78111

79112
This project has a [code of conduct][coc].
@@ -114,26 +147,30 @@ abide by its terms.
114147

115148
[npm]: https://docs.npmjs.com/cli/install
116149

150+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
151+
152+
[esmsh]: https://esm.sh
153+
154+
[typescript]: https://www.typescriptlang.org
155+
117156
[license]: license
118157

119158
[author]: https://wooorm.com
120159

121-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
160+
[health]: https://github.com/syntax-tree/.github
122161

123-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
162+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
124163

125-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
164+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
126165

127-
[mdast]: https://github.com/syntax-tree/mdast
166+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
128167

129-
[tree]: https://github.com/syntax-tree/unist#tree
168+
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
130169

131170
[position-information]: https://github.com/syntax-tree/unist#positional-information
132171

133-
[text]: https://github.com/syntax-tree/mdast#text
134-
135-
[blockquote]: https://github.com/syntax-tree/mdast#blockquote
172+
[mdast]: https://github.com/syntax-tree/mdast
136173

137-
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
174+
[node]: https://github.com/syntax-tree/mdast#node
138175

139176
[hast]: https://github.com/syntax-tree/hast

0 commit comments

Comments
 (0)