1
- # mdast-util-definitions [ ![ Build Status] ( https://img.shields.io/travis/wooorm/mdast-util-definitions.svg )] ( https://travis-ci.org/wooorm/mdast-util-definitions ) [ ![ Coverage Status] ( https://img.shields.io/codecov/c/github/wooorm/mdast-util-definitions.svg )] ( https://codecov.io/github/wooorm/mdast-util-definitions )
1
+ # mdast-util-definitions [ ![ Build Status] [ build-badge ]] [ build-status ] [ ![ Coverage Status] [ coverage-badge ]] [ coverage-status ] [ ![ Chat ] [ chat-badge ]] [ chat ]
2
2
3
- Get a definition in ` node ` by ` identifier ` . Supports weird keys (like
4
- ` __proto__ ` or ` toString ` ).
3
+ <!-- lint disable list-item-spacing heading-increment list-item-indent-->
4
+
5
+ <!-- lint disable no-duplicate-headings-->
6
+
7
+ Get definitions in [ MDAST] [ ] nodes by ` identifier ` . Supports funky
8
+ keys, like ` __proto__ ` or ` toString ` .
5
9
6
10
## Installation
7
11
8
- [ npm] ( https://docs.npmjs.com/cli/install ) :
12
+ [ npm] [ ] :
9
13
10
14
``` bash
11
15
npm install mdast-util-definitions
12
16
```
13
17
14
- ** mdast-util-definitions** is also available for [ duo] ( http://duojs.org/#getting-started )
15
- and as an AMD, CommonJS, and globals module, ([ uncompressed and
16
- compressed] ( https://github.com/wooorm/mdast-util-definitions/releases ) ).
18
+ ** mdast-util-definitions** is also available as an AMD, CommonJS, and
19
+ globals module, [ uncompressed and compressed] [ releases ] .
17
20
18
21
## Usage
19
22
@@ -23,37 +26,67 @@ var definitions = require('mdast-util-definitions');
23
26
24
27
var ast = remark ().parse (' [example]: http://example.com "Example"' );
25
28
26
- var getDefinition = definitions (ast);
29
+ var definition = definitions (ast);
27
30
28
- getDefinition (' example' );
31
+ definition (' example' );
29
32
// {type: 'definition', 'title': 'Example', ...}
30
33
31
- getDefinition (' foo' );
34
+ definition (' foo' );
32
35
// null
33
36
```
34
37
35
38
## API
36
39
37
- ### ` getDefinitionFactory (node): getDefinition `
40
+ ### ` definitions (node)`
38
41
39
42
Create a cache of all ` definition ` s in ` node ` .
40
43
41
- Parameters:
44
+ ###### Parameters
42
45
43
- * ` node ` (` Node ` ) — (Grand)parent of definitions.
46
+ * ` node ` ([ ` Node ` ] [ node ] ) — Ancestor of definitions.
44
47
45
- Returns: ` Function ` — See [ ` getDefinition ` ] ( #getdefinitionidentifier )
48
+ ###### Returns
46
49
47
- ### ` getDefinition(identifier) `
50
+ [ ` Function ` ] [ definition ]
48
51
49
- Get a definition by ` identifier ` .
52
+ ### ` definition( identifier) `
50
53
51
- Parameters:
54
+ ###### Parameters
52
55
53
56
* ` identifier ` (` string ` ) — Identifier of definition.
54
57
55
- Returns: ` Node? ` — Definition, if found.
58
+ ###### Returns
59
+
60
+ [ ` Node? ` ] [ node ] — Definition, if found.
56
61
57
62
## License
58
63
59
- [ MIT] ( LICENSE ) [ @] ( https://github.com/ ) [ Titus Wormer] ( http://wooorm.com )
64
+ [ MIT] [ license ] © [ Titus Wormer] [ author ]
65
+
66
+ <!-- Definitions -->
67
+
68
+ [ build-badge ] : https://img.shields.io/travis/wooorm/mdast-util-definitions.svg
69
+
70
+ [ build-status ] : https://travis-ci.org/wooorm/mdast-util-definitions
71
+
72
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/wooorm/mdast-util-definitions.svg
73
+
74
+ [ coverage-status ] : https://codecov.io/github/wooorm/mdast-util-definitions
75
+
76
+ [ chat-badge ] : https://img.shields.io/gitter/room/wooorm/remark.svg
77
+
78
+ [ chat ] : https://gitter.im/wooorm/remark
79
+
80
+ [ releases ] : https://github.com/wooorm/mdast-util-definitions/releases
81
+
82
+ [ license ] : LICENSE
83
+
84
+ [ author ] : http://wooorm.com
85
+
86
+ [ npm ] : https://docs.npmjs.com/cli/install
87
+
88
+ [ mdast ] : https://github.com/wooorm/mdast
89
+
90
+ [ node ] : https://github.com/wooorm/mdast#node
91
+
92
+ [ definition ] : #definitionidentifier
0 commit comments