.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / mdast-util-compact / readme.md
1 # mdast-util-compact
2
3 [![Build][build-badge]][build]
4 [![Coverage][coverage-badge]][coverage]
5 [![Downloads][downloads-badge]][downloads]
6 [![Size][size-badge]][size]
7 [![Sponsors][sponsors-badge]][collective]
8 [![Backers][backers-badge]][collective]
9 [![Chat][chat-badge]][chat]
10
11 [**mdast**][mdast] utility to make trees compact: collapse text nodes (when
12 possible) and blockquotes (in commonmark mode).
13
14 ## Install
15
16 [npm][]:
17
18 ```sh
19 npm install mdast-util-compact
20 ```
21
22 ## Usage
23
24 ```js
25 var u = require('unist-builder')
26 var compact = require('mdast-util-compact')
27
28 var tree = u('strong', [u('text', 'alpha'), u('text', ' '), u('text', 'bravo')])
29
30 compact(tree)
31
32 console.log(tree)
33 ```
34
35 Yields:
36
37 ```js
38 { type: 'strong',
39   children: [ { type: 'text', value: 'alpha bravo' } ] }
40 ```
41
42 ## API
43
44 ### `compact(tree[, commonmark])`
45
46 Walk the [tree][] and collapse nodes.
47 Combines adjacent [text][]s (but not when they represent entities or escapes).
48 If `commonmark` is `true`, collapses [blockquote][]s.
49
50 Handles [positional information][position-information] properly.
51
52 ###### Returns
53
54 The given `tree`.
55
56 ## Security
57
58 Use of `mdast-util-compact` does not involve [**hast**][hast] or user content
59 so there are no openings for [cross-site scripting (XSS)][xss] attacks.
60
61 ## Contribute
62
63 See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
64 started.
65 See [`support.md`][support] for ways to get help.
66
67 This project has a [Code of Conduct][coc].
68 By interacting with this repository, organisation, or community you agree to
69 abide by its terms.
70
71 ## License
72
73 [MIT][license] © [Titus Wormer][author]
74
75 <!-- Definitions -->
76
77 [build-badge]: https://img.shields.io/travis/syntax-tree/mdast-util-compact.svg
78
79 [build]: https://travis-ci.org/syntax-tree/mdast-util-compact
80
81 [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-compact.svg
82
83 [coverage]: https://codecov.io/github/syntax-tree/mdast-util-compact
84
85 [downloads-badge]: https://img.shields.io/npm/dm/mdast-util-compact.svg
86
87 [downloads]: https://www.npmjs.com/package/mdast-util-compact
88
89 [size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-compact.svg
90
91 [size]: https://bundlephobia.com/result?p=mdast-util-compact
92
93 [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
94
95 [backers-badge]: https://opencollective.com/unified/backers/badge.svg
96
97 [collective]: https://opencollective.com/unified
98
99 [chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
100
101 [chat]: https://spectrum.chat/unified/syntax-tree
102
103 [npm]: https://docs.npmjs.com/cli/install
104
105 [license]: license
106
107 [author]: https://wooorm.com
108
109 [contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
110
111 [support]: https://github.com/syntax-tree/.github/blob/master/support.md
112
113 [coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
114
115 [mdast]: https://github.com/syntax-tree/mdast
116
117 [tree]: https://github.com/syntax-tree/unist#tree
118
119 [position-information]: https://github.com/syntax-tree/unist#positional-information
120
121 [text]: https://github.com/syntax-tree/mdast#text
122
123 [blockquote]: https://github.com/syntax-tree/mdast#blockquote
124
125 [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
126
127 [hast]: https://github.com/syntax-tree/hast