8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ Unist ] [ ] node inspector .
11
+ [ ** unist ** ] [ unist ] utility to inspect nodes .
12
12
13
- ## Installation
13
+ ## Install
14
14
15
15
[ npm] [ ] :
16
16
17
- ``` bash
17
+ ``` sh
18
18
npm install unist-util-inspect
19
19
```
20
20
21
21
## Usage
22
22
23
- ``` javascript
24
- var unified = require (' unified ' )
23
+ ``` js
24
+ var u = require (' unist-builder ' )
25
25
var inspect = require (' unist-util-inspect' )
26
- var parse = require (' rehype-parse' )
27
26
28
- var tree = unified ()
29
- .use (parse)
30
- .parse (' <h2>Hello, world!</h2>' )
27
+ var tree = u (' root' , [
28
+ u (' literal' , ' 1' ),
29
+ u (' parent' , [
30
+ u (' void' , {id: ' a' }),
31
+ u (' literal' , ' 2' ),
32
+ u (' node' , {id: ' b' }, [])
33
+ ])
34
+ ])
31
35
32
36
console .log (inspect (tree))
33
37
```
34
38
35
39
Yields:
36
40
37
41
``` text
38
- root[1] (1:1-1:23, 0-22) [data={"quirksMode":true} ]
39
- └─ element[2] [tagName="html"]
40
- ├─ element[0] [tagName="head" ]
41
- └─ element[1] [tagName="body "]
42
- └─ element[1] (1:1-1:23, 0-22) [tagName="h2"]
43
- └─ text: "Hello, world!" (1:5-1:18, 4-17)
42
+ root[2 ]
43
+ ├─ literal: "1"
44
+ └─ parent[3 ]
45
+ ├─ void [id="a "]
46
+ ├─ literal: "2"
47
+ └─ node[0] [id="b"]
44
48
```
45
49
46
50
## API
@@ -58,7 +62,7 @@ See below on how to change that.
58
62
59
63
` string ` — String representing ` node ` .
60
64
61
- ### ` inspect.<style>[.<style>... ](node) `
65
+ ### ` inspect.<style>[.<style>… ](node) `
62
66
63
67
Where ` <style> ` is either ` color ` or ` noColor ` .
64
68
@@ -67,11 +71,13 @@ or `inspect.noColor(node)`.
67
71
68
72
## Contribute
69
73
70
- See [ ` contributing.md ` in ` syntax-tree/unist ` ] [ contributing ] for ways to get
74
+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
71
75
started.
76
+ See [ ` support.md ` ] [ support ] for ways to get help.
72
77
73
- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
74
- repository, organisation, or community you agree to abide by its terms.
78
+ This project has a [ Code of Conduct] [ coc ] .
79
+ By interacting with this repository, organisation, or community you agree to
80
+ abide by its terms.
75
81
76
82
## License
77
83
@@ -115,6 +121,8 @@ repository, organisation, or community you agree to abide by its terms.
115
121
116
122
[ author ] : https://wooorm.com
117
123
118
- [ contributing ] : https://github.com/syntax-tree/unist /blob/master/contributing.md
124
+ [ contributing ] : https://github.com/syntax-tree/.github /blob/master/contributing.md
119
125
120
- [ coc ] : https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md
126
+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
127
+
128
+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
0 commit comments