1 | [![npm](https://nodei.co/npm/mdast-squeeze-paragraphs.png)](https://npmjs.com/package/mdast-squeeze-paragraphs)
|
2 |
|
3 | # mdast-squeeze-paragraphs
|
4 |
|
5 | [![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david]
|
6 |
|
7 | > :warning:
|
8 | >
|
9 | > This is an AST transformer for [mdast] syntax trees. A [remark] plugin has been split up into [a different project][remark-squeeze-paragraphs].
|
10 |
|
11 | Remove empty paragraphs from [mdast] tree.
|
12 |
|
13 | Paragraph is considered empty if it is composed of whitespace characters only.
|
14 |
|
15 | [mdast]: https://github.com/wooorm/mdast
|
16 | [remark]: https://github.com/wooorm/remark
|
17 | [remark-squeeze-paragraphs]: https://github.com/eush77/remark-squeeze-paragraphs
|
18 |
|
19 | [travis]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs
|
20 | [travis-badge]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs.svg
|
21 | [david]: https://david-dm.org/eush77/mdast-squeeze-paragraphs
|
22 | [david-badge]: https://david-dm.org/eush77/mdast-squeeze-paragraphs.png
|
23 |
|
24 | ## Example
|
25 |
|
26 | ```js
|
27 | var squeezeParagraphs = require('mdast-squeeze-paragraphs');
|
28 |
|
29 | ast
|
30 | //=> {
|
31 | // "type": "root",
|
32 | // "children": [
|
33 | // {
|
34 | // "type": "paragraph",
|
35 | // "children": []
|
36 | // },
|
37 | // {
|
38 | // "type": "paragraph",
|
39 | // "children": [
|
40 | // {
|
41 | // "type": "text",
|
42 | // "value": "foo"
|
43 | // }
|
44 | // ]
|
45 | // }
|
46 | // ]
|
47 | // }
|
48 |
|
49 | squeezeParagraphs(ast)
|
50 | //=> {
|
51 | // "type": "root",
|
52 | // "children": [
|
53 | // {
|
54 | // "type": "paragraph",
|
55 | // "children": [
|
56 | // {
|
57 | // "type": "text",
|
58 | // "value": "foo"
|
59 | // }
|
60 | // ]
|
61 | // }
|
62 | // ]
|
63 | // }
|
64 | ```
|
65 |
|
66 | ## API
|
67 |
|
68 | #### `squeezeParagraphs(ast)`
|
69 |
|
70 | Modifies AST in-place. Returns `ast`.
|
71 |
|
72 | ## Related
|
73 |
|
74 | - [remark-squeeze-paragraphs] — [remark] plugin wrapper.
|
75 |
|
76 | ## Install
|
77 |
|
78 | ```
|
79 | npm install mdast-squeeze-paragraphs
|
80 | ```
|
81 |
|
82 | ## License
|
83 |
|
84 | MIT
|