File tree 1 file changed +23
-16
lines changed
1 file changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -13,26 +13,33 @@ npm install unist-util-source
13
13
14
14
## Usage
15
15
16
- ``` js
17
- var remark = require (' remark' );
18
- var source = require (' ./' );
19
-
20
- remark ()
21
- .use (function () {
22
- return transformer;
23
- function transformer (tree , file ) {
24
- var list = tree .children [0 ].children [0 ];
25
- console .log (source (list, file));
26
- }
27
- })
28
- .processSync (' > + **[Hello](./example)**\n > world.' );
16
+ Say we have the following file, ` example.md ` :
17
+
18
+ ``` markdown
19
+ > + **[Hello](./example)**
20
+ > world.
21
+ ```
22
+
23
+ And our script, ` example.js ` , looks as follows:
24
+
25
+ ``` javascript
26
+ var vfile = require (' to-vfile' );
27
+ var unified = require (' unified' );
28
+ var parse = require (' remark-parse' );
29
+ var source = require (' unist-util-source' );
30
+
31
+ var file = vfile .readSync (' example.md' );
32
+ var tree = unified ().use (parse).parse (file);
33
+
34
+ var list = tree .children [0 ].children [0 ];
35
+ console .log (source (list, file));
29
36
```
30
37
31
- Yields :
38
+ Now, running ` node example ` yields :
32
39
33
- ``` txt
40
+ ``` markdown
34
41
+ **[Hello](./example)**
35
- world.
42
+ world.
36
43
```
37
44
38
45
## API
You can’t perform that action at this time.
0 commit comments