File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,30 @@ npm install mdast-util-to-hast
14
14
15
15
## Usage
16
16
17
+ Say we have the following ` example.md ` :
18
+
19
+ ``` markdown
20
+ ## Hello **World**!
21
+ ```
22
+
23
+ ...and next to it, ` example.js ` :
24
+
17
25
``` javascript
18
26
var inspect = require (' unist-util-inspect' );
19
- var remark = require (' remark' );
27
+ var unified = require (' unified' );
28
+ var parse = require (' remark-parse' );
29
+ var vfile = require (' to-vfile' );
20
30
var toHAST = require (' mdast-util-to-hast' );
21
31
22
- var hast = toHAST (remark ().parse (' ## Hello **World**!' ));
23
- console .log (inspect (hast));
32
+ var tree = unified ().use (parse).parse (vfile .readSync (' example.md' ));
33
+
34
+ console .log (inspect (toHAST (tree)));
24
35
```
25
36
26
- Yields :
37
+ Which when running with ` node example ` yields :
27
38
28
39
``` txt
29
- root[1] (1:1-1:20 , 0-19 )
40
+ root[1] (1:1-2:1 , 0-20 )
30
41
└─ element[3] (1:1-1:20, 0-19) [tagName="h2"]
31
42
├─ text: "Hello " (1:4-1:10, 3-9)
32
43
├─ element[1] (1:10-1:19, 9-18) [tagName="strong"]
You can’t perform that action at this time.
0 commit comments