1
- # hast-util-from-dom
1
+ # hast-util-from-dom [ ![ Build Status ] [ travis-badge ]] [ travis ]
2
2
3
3
Transform a DOM tree to [ HAST] [ ]
4
4
@@ -23,7 +23,7 @@ This utility is similar to [`hast-util-from-parse5`][hast-util-from-parse5], but
23
23
Say we have the following file, ` example.html ` :
24
24
25
25
``` html
26
- <!doctype html><title >Hello!</title ><h1 id =" world" >World!<!-- after--> <script src =" example.js" ></script >
26
+ <!doctype html><title >Hello!</title ><h1 id =" world" >World!<!-- after--> <script src =" example.js" charset = " UTF-8 " ></script >
27
27
```
28
28
29
29
Suppose ` example.js ` is a bundled version of something like this:
@@ -34,7 +34,7 @@ import fromDOM from 'hast-util-from-dom';
34
34
35
35
const hast = fromDOM (document .documentElement .parentNode );
36
36
37
- console .log (inspect (hast));
37
+ console .log (inspect . noColor (hast));
38
38
```
39
39
40
40
Viewing ` example.html ` should yield the following in the console:
@@ -43,14 +43,14 @@ Viewing `example.html` should yield the following in the console:
43
43
root[2]
44
44
├─ doctype [name="html"]
45
45
└─ element[2] [tagName="html"]
46
- ├─ element[1] [tagName="head"]
47
- │ └─ element[1] [tagName="title"]
48
- │ └─ text: "Hello!"
49
- └─ element[1] [tagName="body"]
46
+ ├─ element[1] [tagName="head"]
47
+ │ └─ element[1] [tagName="title"]
48
+ │ └─ text: "Hello!"
49
+ └─ element[1] [tagName="body"]
50
50
└─ element[3] [tagName="h1"][properties={"id":"world"}]
51
- ├─ text: "World!"
52
- ├─ comment: "after"
53
- └─ element[0] [tagName="script"][properties={"src":"example.js"}]
51
+ ├─ text: "World!"
52
+ ├─ comment: "after"
53
+ └─ element[0] [tagName="script"][properties={"src":"example.js","charSet":"UTF-8 "}]
54
54
```
55
55
56
56
## API
@@ -67,6 +67,10 @@ This works in a similar way to the `parse5` version except that it works directl
67
67
68
68
<!-- Definitions -->
69
69
70
+ [ travis-badge ] : https://img.shields.io/travis/kmck/hast-util-from-dom.svg
71
+
72
+ [ travis ] : https://travis-ci.org/kmck/hast-util-from-dom
73
+
70
74
[ yarn ] : https://yarnpkg.com/lang/en/docs/install
71
75
72
76
[ npm ] : https://docs.npmjs.com/cli/install
0 commit comments