Skip to content

Commit 88e406b

Browse files
committed
Update example in readme.md
1 parent 9fc1a20 commit 88e406b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

readme.md

+16-5
Original file line numberDiff line numberDiff 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
1826
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');
2030
var 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"]

0 commit comments

Comments
 (0)