Skip to content

Commit e75a23b

Browse files
committed
Update readme.md
1 parent 4f3e76b commit e75a23b

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

readme.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,40 @@ var parse5 = require('parse5')
3535
var inspect = require('unist-util-inspect')
3636
var fromParse5 = require('hast-util-from-parse5')
3737

38-
var doc = vfile.readSync('example.html')
39-
var ast = parse5.parse(String(doc), {sourceCodeLocationInfo: true})
40-
var hast = fromParse5(ast, doc)
38+
var file = vfile.readSync('example.html')
39+
var p5ast = parse5.parse(String(file), {sourceCodeLocationInfo: true})
40+
var hast = fromParse5(p5ast, file)
4141

4242
console.log(inspect(hast))
4343
```
4444

4545
Now, running `node example` yields:
4646

4747
```text
48-
root[2] (1:1-2:1, 0-70) [data={"quirksMode":false}]
49-
├─ doctype (1:1-1:16, 0-15) [name="html"]
50-
└─ element[2] [tagName="html"]
51-
├─ element[1] [tagName="head"]
52-
│ └─ element[1] (1:16-1:37, 15-36) [tagName="title"]
53-
│ └─ text: "Hello!" (1:23-1:29, 22-28)
54-
└─ element[1] [tagName="body"]
55-
└─ element[3] (1:37-2:1, 36-70) [tagName="h1"][properties={"id":"world"}]
56-
├─ text: "World!" (1:52-1:58, 51-57)
57-
├─ comment: "after" (1:58-1:70, 57-69)
58-
└─ text: "\n" (1:70-2:1, 69-70)
48+
root[2] (1:1-2:1, 0-70)
49+
│ data: {"quirksMode":false}
50+
├─0 doctype<html> (1:1-1:16, 0-15)
51+
│ public: null
52+
│ system: null
53+
└─1 element<html>[2]
54+
│ properties: {}
55+
├─0 element<head>[1]
56+
│ │ properties: {}
57+
│ └─0 element<title>[1] (1:16-1:37, 15-36)
58+
│ │ properties: {}
59+
│ └─0 text "Hello!" (1:23-1:29, 22-28)
60+
└─1 element<body>[1]
61+
│ properties: {}
62+
└─0 element<h1>[3] (1:37-2:1, 36-70)
63+
│ properties: {"id":"world"}
64+
├─0 text "World!" (1:52-1:58, 51-57)
65+
├─1 comment "after" (1:58-1:70, 57-69)
66+
└─2 text "\n" (1:70-2:1, 69-70)
5967
```
6068

6169
## API
6270

63-
### `fromParse5(ast[, options])`
71+
### `fromParse5(ast[, file|options])`
6472

6573
Transform [Parse5’s AST][ast] to a [**hast**][hast] [*tree*][tree].
6674

0 commit comments

Comments
 (0)