File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 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
1414
1515## Usage
1616
17+ Say we have the following ` example.md ` :
18+
19+ ``` markdown
20+ ## Hello **World**!
21+ ```
22+
23+ ...and next to it, ` example.js ` :
24+
1725``` javascript
1826var 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' );
2030var toHAST = require (' mdast-util-to-hast' );
2131
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)));
2435```
2536
26- Yields :
37+ Which when running with ` node example ` yields :
2738
2839``` txt
29- root[1] (1:1-1:20 , 0-19 )
40+ root[1] (1:1-2:1 , 0-20 )
3041└─ element[3] (1:1-1:20, 0-19) [tagName="h2"]
3142 ├─ text: "Hello " (1:4-1:10, 3-9)
3243 ├─ element[1] (1:10-1:19, 9-18) [tagName="strong"]
You can’t perform that action at this time.
0 commit comments