Skip to content

Commit 3d52348

Browse files
committed
Refactor readme.md
1 parent 3e56f7c commit 3d52348

File tree

2 files changed

+72
-62
lines changed

2 files changed

+72
-62
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232
"devDependencies": {
3333
"nyc": "^12.0.2",
3434
"prettier": "^1.14.2",
35+
"remark-cli": "^5.0.0",
36+
"remark-preset-wooorm": "^4.0.0",
3537
"tape": "^4.0.0",
3638
"unist-builder": "^1.0.0",
3739
"xo": "^0.22.0"
3840
},
3941
"scripts": {
40-
"format": "prettier --write \"**/*.js\" && xo --fix",
42+
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
4143
"test-api": "node test",
4244
"test-coverage": "nyc --reporter lcov tape test.js",
4345
"test": "npm run format && npm run test-coverage"
@@ -59,5 +61,10 @@
5961
"xo": {
6062
"prettier": true,
6163
"esnext": false
64+
},
65+
"remarkConfig": {
66+
"plugins": [
67+
"preset-wooorm"
68+
]
6269
}
6370
}

readme.md

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,87 @@
1-
[![npm](https://nodei.co/npm/mdast-squeeze-paragraphs.png)](https://npmjs.com/package/mdast-squeeze-paragraphs)
1+
# mdast-squeeze-paragraphs [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
22

3-
# mdast-squeeze-paragraphs
3+
Remove empty paragraphs from [**mdast**][mdast] syntax trees.
44

5-
[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david]
5+
Paragraphs are considered empty if they do not contain non-whitespace
6+
characters.
67

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].
8+
## Installation
109

11-
Remove empty paragraphs from [mdast][] tree.
10+
[npm][]:
1211

13-
Paragraph is considered empty if it is composed of whitespace characters only.
12+
```bash
13+
npm install mdast-squeeze-paragraphs
14+
```
1415

15-
[mdast]: https://github.com/syntax-tree/mdast
16-
[remark]: https://github.com/wooorm/remark
17-
[remark-squeeze-paragraphs]: https://github.com/eush77/remark-squeeze-paragraphs
16+
## Usage
1817

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
18+
```js
19+
var u = require('unist-builder')
20+
var squeezeParagraphs = require('mdast-squeeze-paragraphs')
2321

24-
## Example
22+
var tree = u('root', [
23+
u('paragraph', []),
24+
u('paragraph', [u('text', 'Alpha')]),
25+
u('paragraph', [u('text', ' ')])
26+
])
27+
28+
squeezeParagraphs(tree)
29+
30+
console.dir(tree, {depth: null})
31+
```
32+
33+
Yields:
2534

2635
```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-
// }
36+
{ type: 'root',
37+
children:
38+
[ { type: 'paragraph',
39+
children: [ { type: 'text', value: 'Alpha' } ] } ] }
6440
```
6541

6642
## API
6743

68-
#### `squeezeParagraphs(ast)`
44+
### `squeezeParagraphs(tree)`
6945

70-
Modifies AST in-place. Returns `ast`.
46+
Modifies tree in-place. Returns `tree`.
7147

7248
## Related
7349

74-
- [remark-squeeze-paragraphs][][remark][] plugin wrapper.
50+
* [`remark-squeeze-paragraphs`][squeeze-paragraphs]
51+
[**remark**][remark] plugin wrapper
7552

76-
## Install
53+
## Contribute
7754

78-
```
79-
npm install mdast-squeeze-paragraphs
80-
```
55+
See [`contributing.md` in `syntax-tree/mdast`][contributing] for ways to get
56+
started.
57+
58+
This organisation has a [Code of Conduct][coc]. By interacting with this
59+
repository, organisation, or community you agree to abide by its terms.
8160

8261
## License
8362

84-
MIT
63+
[MIT][license] © Eugene Sharygin
64+
65+
<!-- Definitions -->
66+
67+
[travis-badge]: https://img.shields.io/travis/syntax-tree/mdast-squeeze-paragraphs.svg
68+
69+
[travis]: https://travis-ci.org/syntax-tree/mdast-squeeze-paragraphs
70+
71+
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-squeeze-paragraphs.svg
72+
73+
[codecov]: https://codecov.io/github/syntax-tree/mdast-squeeze-paragraphs
74+
75+
[npm]: https://docs.npmjs.com/cli/install
76+
77+
[license]: license
78+
79+
[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md
80+
81+
[coc]: https://github.com/syntax-tree/mdast/blob/master/code-of-conduct.md
82+
83+
[mdast]: https://github.com/syntax-tree/mdast
84+
85+
[remark]: https://github.com/remarkjs/remark
86+
87+
[squeeze-paragraphs]: https://github.com/remarkjs/remark-squeeze-paragraphs

0 commit comments

Comments
 (0)