Skip to content

Commit 2caf653

Browse files
committed
Refactor docs
1 parent 2e4d6dd commit 2caf653

File tree

1 file changed

+45
-52
lines changed

1 file changed

+45
-52
lines changed

readme.md

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,75 @@
1-
# unist-util-find-after [![Build Status](https://img.shields.io/travis/wooorm/unist-util-find-after.svg)](https://travis-ci.org/wooorm/unist-util-find-after) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/unist-util-find-after.svg)](https://codecov.io/github/wooorm/unist-util-find-after?branch=master)
1+
# unist-util-find-after [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
22

3-
[**Unist**](https://github.com/wooorm/unist) utility to find a node after
4-
another node. Useful when working with [**mdast**](https://github.com/wooorm/mdast)
5-
or [**retext**](https://github.com/wooorm/retext).
3+
[**Unist**][unist] utility to find a node after another node.
64

75
## Installation
86

9-
[npm](https://docs.npmjs.com/cli/install):
7+
[npm][]:
108

119
```bash
1210
npm install unist-util-find-after
1311
```
1412

15-
**unist-util-find-after** is also available for [bower](http://bower.io/#install-packages),
16-
[component](https://github.com/componentjs/component), and
17-
[duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and globals
18-
module, [uncompressed](unist-util-find-after.js) and
19-
[compressed](unist-util-find-after.min.js).
20-
2113
## Usage
2214

2315
```js
24-
var mdast = require('mdast');
16+
var remark = require('remark');
2517
var findAfter = require('unist-util-find-after');
26-
var inspect = require('unist-util-inspect');
27-
28-
function log(node) {
29-
console.log(node && inspect(node));
30-
}
31-
32-
mdast.use(function () {
33-
return function (ast) {
34-
var paragraph = ast.children[0];
35-
var children = paragraph.children;
36-
37-
log(findAfter(paragraph, 1));
38-
log(findAfter(paragraph, children[1]));
39-
log(findAfter(paragraph, children[1], 'strong'));
40-
log(findAfter(paragraph, children[1], children[0]));
41-
log(findAfter(paragraph, children[1], function (node, n) {
42-
return n === 5;
43-
}));
44-
};
45-
}).process('Some *emphasis*, **strongness**, and `code`.');
18+
19+
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.');
20+
var paragraph = tree.children[0];
21+
22+
console.log(findAfter(paragraph, 1, 'strong'));
4623
```
4724

4825
Yields:
4926

50-
```text
51-
text: ', '
52-
text: ', '
53-
strong[1]
54-
└─ text: 'strongness'
55-
null
56-
inlineCode: 'code'
27+
```js
28+
{ type: 'strong',
29+
children: [ { type: 'text', value: 'importance' } ] }
5730
```
5831

5932
## API
6033

61-
### findAfter(parent, index|node\[, test])
34+
### `findAfter(parent, node|index[, test])`
6235

63-
Find the first child after `index` (or `node`), that passes `test` (when
64-
given).
36+
Find the first child after `index` (or `node`) in `parent`, that passes `test`
37+
(when given).
6538

66-
**Parameters**:
39+
###### Parameters
6740

68-
* `parent` (`Node`) — Parent to search in;
41+
* `parent` ([`Node`][node]) — Context node;
42+
* `node` ([`Node`][node]) — Node in `parent`;
43+
* `index` (`number`, optional) — Position of a `node` in `parent`;
44+
* `test` (`Function`, `string`, or `Node`, optional)
45+
— See [`unist-util-is`][is].
6946

70-
* `node` (`Node`)
71-
[Node](https://github.com/wooorm/unist#unist-nodes) to search after;
47+
###### Returns
7248

73-
* `index` (`number`) — Position of child to search after;
49+
[`Node?`][node] — Child node of `parent` passing `test`.
7450

75-
* `test` (`Function`, `string`, or `Node`; optional)
76-
— See [`is()`](https://github.com/wooorm/unist-util-is#istest-node-index-parent-context).
51+
## License
7752

78-
**Returns**: `node?`, when found. Child node of `parent` which passes `test`.
53+
[MIT][license] © [Titus Wormer][author]
7954

80-
## License
55+
<!-- Definitions -->
56+
57+
[travis-badge]: https://img.shields.io/travis/wooorm/unist-util-find-after.svg
58+
59+
[travis]: https://travis-ci.org/wooorm/unist-util-find-after
60+
61+
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/unist-util-find-after.svg
62+
63+
[codecov]: https://codecov.io/github/wooorm/unist-util-find-after
64+
65+
[npm]: https://docs.npmjs.com/cli/install
66+
67+
[license]: LICENSE
68+
69+
[author]: http://wooorm.com
70+
71+
[unist]: https://github.com/wooorm/unist
72+
73+
[node]: https://github.com/wooorm/unist#node
8174

82-
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)
75+
[is]: https://github.com/wooorm/unist-util-is

0 commit comments

Comments
 (0)