8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
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.
13
13
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.
15
18
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?
18
20
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] [ ] :
20
28
21
29
``` sh
22
30
npm install mdast-util-compact
23
31
```
24
32
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
+
25
47
## Use
26
48
27
49
``` js
@@ -46,24 +68,35 @@ Yields:
46
68
47
69
## API
48
70
49
- This package exports the following identifiers: ` compact ` .
71
+ This package exports the identifier ` compact ` .
50
72
There is no default export.
51
73
52
74
### ` compact(tree) `
53
75
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.
57
78
Handles [ positional information] [ position-information ] properly.
58
79
59
80
###### Returns
60
81
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.
62
95
63
96
## Security
64
97
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.
67
100
68
101
## Related
69
102
@@ -72,8 +105,8 @@ so there are no openings for [cross-site scripting (XSS)][xss] attacks.
72
105
73
106
## Contribute
74
107
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.
77
110
See [ ` support.md ` ] [ support ] for ways to get help.
78
111
79
112
This project has a [ code of conduct] [ coc ] .
@@ -114,26 +147,30 @@ abide by its terms.
114
147
115
148
[ npm ] : https://docs.npmjs.com/cli/install
116
149
150
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
151
+
152
+ [ esmsh ] : https://esm.sh
153
+
154
+ [ typescript ] : https://www.typescriptlang.org
155
+
117
156
[ license ] : license
118
157
119
158
[ author ] : https://wooorm.com
120
159
121
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
160
+ [ health ] : https://github.com/syntax-tree/.github
122
161
123
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
162
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
124
163
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
126
165
127
- [ mdast ] : https://github.com/syntax-tree/mdast
166
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
128
167
129
- [ tree ] : https://github.com/syntax-tree/unist#tree
168
+ [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
130
169
131
170
[ position-information ] : https://github.com/syntax-tree/unist#positional-information
132
171
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
136
173
137
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
174
+ [ node ] : https://github.com/syntax-tree/mdast#node
138
175
139
176
[ hast ] : https://github.com/syntax-tree/hast
0 commit comments