File tree Expand file tree Collapse file tree 1 file changed +23
-16
lines changed Expand file tree Collapse file tree 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
1313
1414## Usage
1515
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));
2936```
3037
31- Yields :
38+ Now, running ` node example ` yields :
3239
33- ``` txt
40+ ``` markdown
3441+ **[Hello](./example)**
35- world.
42+ world.
3643```
3744
3845## API
You can’t perform that action at this time.
0 commit comments