@@ -13,57 +13,57 @@ npm install --save unist-util-find
1313### Example
1414
1515``` js
16- import {remark } from ' remark'
17- import {find } from ' unist-util-find'
18-
19- remark ()
20- .use (function () {
21- return function (tree ) {
22- // string condition
23- console .log (find (tree, ' value' ))
24-
25- // object condition
26- console .log (find (tree, { value: ' emphasis' }))
27-
28- // function condition
29- console .log (find (tree, function (node ) {
30- return node .type === ' inlineCode'
31- }))
32- }
33- })
34- .processSync (' Some _emphasis_, **strongness**, and `code`.' )
16+ import {fromMarkdown } from ' mdast-util-from-markdown'
17+ import {find } from ' ./index.js'
18+
19+ const tree = fromMarkdown (' Some _emphasis_, **strongness**, and `code`.' )
20+
21+ // String condition
22+ console .log (find (tree, ' value' ))
3523
24+ // Object condition
25+ console .log (find (tree, {value: ' emphasis' }))
26+
27+ // Function condition
28+ console .log (
29+ find (tree, function (node ) {
30+ return node .type === ' inlineCode'
31+ })
32+ )
3633```
3734
3835Result:
3936
4037```
4138// string condition: 'value'
42- { type: 'text',
39+ {
40+ type: 'text',
4341 value: 'Some ',
44- position:
45- Position {
46- start : { line: 1, column: 1 , offset: 0 },
47- end: { line: 1, column: 6, offset: 5 },
48- indent: [] } }
42+ position: {
43+ start: { line: 1, column: 1, offset: 0 },
44+ end : { line: 1, column: 6 , offset: 5 }
45+ }
46+ }
4947
5048// object condition: { value: 'emphasis' }
51- { type: 'text',
49+ {
50+ type: 'text',
5251 value: 'emphasis',
53- position:
54- Position {
55- start : { line: 1, column: 7 , offset: 6 },
56- end: { line: 1, column: 15, offset: 14 },
57- indent: [] } }
52+ position: {
53+ start: { line: 1, column: 7, offset: 6 },
54+ end : { line: 1, column: 15 , offset: 14 }
55+ }
56+ }
5857
5958// function condition: function (node) { return node.type === 'inlineCode' }
60- { type: 'inlineCode',
59+ {
60+ type: 'inlineCode',
6161 value: 'code',
62- position:
63- Position {
64- start : { line: 1, column: 38 , offset: 37 },
65- end: { line: 1, column: 44, offset: 43 },
66- indent: [] } }
62+ position: {
63+ start: { line: 1, column: 38, offset: 37 },
64+ end : { line: 1, column: 44 , offset: 43 }
65+ }
66+ }
6767```
6868
6969### API
0 commit comments