Miss any of our Open RFC calls?Watch the recordings here! »

unist-util-visit-all-after

1.0.0 • Public • Published

unist-util-visit-all-after

Unist node visitor. Utility to visit nodes after another node.

Install

npm install -S unist-util-visit-all-after

Usage

text.txt

A whole lot of dogs, dogs, dogs.

index.js

var vfile = require('to-vfile')
var unified = require('unified')
var english = require('retext-english')
var stringify = require('retext-stringify')
var after = require('unist-util-visit-all-after')
 
function cats () {
    return function (tree) {
        var start = {
            type: 'TextNode',
            value: 'of'
        }
        var test = 'TextNode'
        after(tree, start, test, function (node) {
            node.value = 'cats'
        })
    }
}
 
unified()
    .use(english)
    .use(stringify)
    .use(cats)
    .process(vfile.readSync('text.txt'), function (error, file) {
        console.log(String(file))
    })

outputs,

A whole lot of cats, cats, cats.

License

MIT © Paul Zimmer

Install

npm i unist-util-visit-all-after

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

2.55 kB

Total Files

3

Last publish

Collaborators

  • avatar