UNPKG

2.34 kBMarkdownView Raw
1# mdast-squeeze-paragraphs [![Build][build-badge]][build] [![Coverage][coverage-badge]][coverage] [![Downloads][downloads-badge]][downloads] [![Chat][chat-badge]][chat]
2
3Remove empty paragraphs from [**mdast**][mdast] syntax trees.
4
5Paragraphs are considered empty if they do not contain non-whitespace
6characters.
7
8## Installation
9
10[npm][]:
11
12```bash
13npm install mdast-squeeze-paragraphs
14```
15
16## Usage
17
18```js
19var u = require('unist-builder')
20var squeezeParagraphs = require('mdast-squeeze-paragraphs')
21
22var tree = u('root', [
23 u('paragraph', []),
24 u('paragraph', [u('text', 'Alpha')]),
25 u('paragraph', [u('text', ' ')])
26])
27
28squeezeParagraphs(tree)
29
30console.dir(tree, {depth: null})
31```
32
33Yields:
34
35```js
36{ type: 'root',
37 children:
38 [ { type: 'paragraph',
39 children: [ { type: 'text', value: 'Alpha' } ] } ] }
40```
41
42## API
43
44### `squeezeParagraphs(tree)`
45
46Modifies tree in-place. Returns `tree`.
47
48## Related
49
50* [`remark-squeeze-paragraphs`][squeeze-paragraphs]
51 — [**remark**][remark] plugin wrapper
52
53## Contribute
54
55See [`contributing.md` in `syntax-tree/mdast`][contributing] for ways to get
56started.
57
58This organisation has a [Code of Conduct][coc]. By interacting with this
59repository, organisation, or community you agree to abide by its terms.
60
61## License
62
63[MIT][license] © Eugene Sharygin
64
65<!-- Definitions -->
66
67[build-badge]: https://img.shields.io/travis/syntax-tree/mdast-squeeze-paragraphs.svg
68
69[build]: https://travis-ci.org/syntax-tree/mdast-squeeze-paragraphs
70
71[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-squeeze-paragraphs.svg
72
73[coverage]: https://codecov.io/github/syntax-tree/mdast-squeeze-paragraphs
74
75[downloads-badge]: https://img.shields.io/npm/dm/mdast-squeeze-paragraphs.svg
76
77[downloads]: https://www.npmjs.com/package/mdast-squeeze-paragraphs
78
79[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
80
81[chat]: https://spectrum.chat/unified/remark
82
83[npm]: https://docs.npmjs.com/cli/install
84
85[license]: license
86
87[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md
88
89[coc]: https://github.com/syntax-tree/mdast/blob/master/code-of-conduct.md
90
91[mdast]: https://github.com/syntax-tree/mdast
92
93[remark]: https://github.com/remarkjs/remark
94
95[squeeze-paragraphs]: https://github.com/remarkjs/remark-squeeze-paragraphs