1
- # mdast-util-position [ ![ Build Status] ( https://img.shields.io/ travis/wooorm/mdast-util-position.svg )] ( https:// travis-ci.org/wooorm/mdast-util-position ) [ ![ Coverage Status] ( https://img.shields.io/codecov/c/github/wooorm/mdast-util-position.svg )] ( https://codecov.io/github/wooorm/mdast-util-position )
1
+ # mdast-util-position [ ![ Build Status] [ travis-badge ]] [ travis ] [ ![ Coverage Status] [ coverage-badge ]] [ coverage ]
2
2
3
- [ ** mdast** ] ( https://github.com/wooorm/mdast ) utility to get the position
4
- of nodes.
3
+ [ ** mdast** ] [ mdast ] utility to get the position of nodes.
5
4
6
5
* Supports index-based positional information patched by
7
- [ ** mdast-range** ] ( https://github.com/wooorm/ mdast-range) ;
6
+ [ ** mdast-range** ] [ mdast-range ] ;
8
7
9
- * Supports [ ` indent ` ] ( https://github.com/wooorm/mdast#location ) .
8
+ * Supports [ ` indent ` ] [ mdast-indent ] .
9
+
10
+ Utility to get the style of an [ ** mdast** ] [ mdast ] heading.
10
11
11
12
## Installation
12
13
13
- [ npm] ( https://docs.npmjs.com/cli/ install) :
14
+ [ npm] [ npm- install] :
14
15
15
16
``` bash
16
17
npm install mdast-util-position
17
18
```
18
19
19
- ** mdast-util-position** is also available for [ duo] ( http://duojs.org/#getting-started ) ,
20
- and as an AMD, CommonJS, and globals module, [ uncompressed and
21
- compressed] ( https://github.com/wooorm/mdast-util-position/ releases) .
20
+ ** mdast-util-position** is also available for [ duo] [ ] ,
21
+ and as an AMD, CommonJS, and globals module,
22
+ [ uncompressed and compressed] [ releases ] .
22
23
23
24
## Usage
24
25
25
26
``` js
26
- var mdast = require (' mdast ' );
27
+ var remark = require (' remark ' );
27
28
var position = require (' mdast-util-position' );
28
29
29
- var ast = mdast .parse (` # foo
30
-
31
- * bar
32
- ` );
30
+ var ast = remark .parse ([
31
+ ' # foo' ,
32
+ ' ' ,
33
+ ' * bar' ,
34
+ ' '
35
+ ].join (' \n ' ));
33
36
34
37
position .start (ast) // {line: 1, column: 1}
35
38
position .end (ast) // {line: 4, column: 1}
@@ -42,30 +45,61 @@ position.generated() // true
42
45
43
46
## API
44
47
45
- ### position.start(node?)
48
+ ### ` position.start([node]) `
49
+
50
+ ### ` position.end([node]) `
46
51
47
- ### position.end( node?)
52
+ Get the heading style of a node.
48
53
49
- Parameters:
54
+ ** Parameters** :
50
55
51
- * ` node ` (optional [ ` Node ` ] ( https://github.com/wooorm/mdast/blob/master/doc/nodes.md#node ) )
52
- — Node to check
56
+ * ` node ` ([ ` Node ` ] [ mdast-node ] ) — Node to check;
53
57
54
- Returns: [ ` Position ` ] ( https://github.com/wooorm/mdast/blob/master/doc/nodes.md#position )
55
- — Filled with ` line ` (nullable ` uint32 >= 1 ` ) and ` column ` (nullable
56
- ` uint32 >= 1 ` ).
58
+ ** Returns** ([ ` Position ` ] [ mdast-position ] ) — Filled with ` line `
59
+ (nullable ` uint32 >= 1 ` ) and ` column ` (nullable ` uint32 >= 1 ` ).
57
60
58
- ### position.generated(node?)
61
+ ### ` position.generated([ node]) `
59
62
60
- Parameters:
63
+ Get the heading style of a node.
61
64
62
- * ` node ` (optional [ ` Node ` ] ( https://github.com/wooorm/mdast/blob/master/doc/nodes.md#node ) )
63
- — Node to check
65
+ ** Parameters** :
64
66
65
- Returns: ` boolean ` , whether or not ` node ` has positional information (both
66
- starting and ending lines and columns). This is useful when checking if a node
67
- is inserted by plug-ins.
67
+ * ` node ` ([ ` Node ` ] [ mdast-node ] ) — Node to check;
68
+
69
+ ** Returns** (` boolean ` ) — Whether or not ` node ` has positional
70
+ information (both starting and ending lines and columns). This is
71
+ useful when checking if a node is inserted by plug-ins.
68
72
69
73
## License
70
74
71
- [ MIT] ( LICENSE ) © [ Titus Wormer] ( http://wooorm.com )
75
+ [ MIT] [ license ] © [ Titus Wormer] [ home ]
76
+
77
+ <!-- Definitions -->
78
+
79
+ [ travis-badge ] : https://img.shields.io/travis/wooorm/mdast-util-position.svg
80
+
81
+ [ travis ] : https://travis-ci.org/wooorm/mdast-util-position
82
+
83
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/wooorm/mdast-util-position.svg
84
+
85
+ [ coverage ] : https://codecov.io/github/wooorm/mdast-util-position
86
+
87
+ [ mdast ] : https://github.com/wooorm/mdast
88
+
89
+ [ mdast-node ] : https://github.com/wooorm/mdast#node
90
+
91
+ [ mdast-range ] : https://github.com/wooorm/mdast-range
92
+
93
+ [ mdast-indent ] : https://github.com/wooorm/mdast#location
94
+
95
+ [ mdast-position ] : https://github.com/wooorm/mdast/blob/master/doc/nodes.md#position
96
+
97
+ [ npm-install ] : https://docs.npmjs.com/cli/install
98
+
99
+ [ duo ] : http://duojs.org/#getting-started
100
+
101
+ [ releases ] : https://github.com/wooorm/mdast-util-position/releases
102
+
103
+ [ license ] : LICENSE
104
+
105
+ [ home ] : http://wooorm.com
0 commit comments