retext-visit
See Browser Support for more information (a.k.a. don’t worry about those grey icons above).
retext node visitor.
Installation
NPM:
$ npm install retext-visit
Component.js:
$ component install wooorm/retext-visit
Usage
var Retext = require('retext'),
visit = require('retext-visit');
var root = new Retext()
.use(visit)
.parse('A simple english sentence.');
API
Node#visit(callback)
root.head.head.visit(function (node) {
console.log(node.toString());
});
Visit every node inside the operated on node.
callback
(function
): The function to call with each node.
When callback return false, stops iterating.
Node#visitType(type, callback)
root.visitType(root.WORD_NODE, function (wordNode) {
console.log(wordNode.toString());
});
Visit every node of type type
inside the operated on node.
type
: A type of a node (e.g., PARAGRAPH_NODE, WORD_NODE, or WHITE_SPACE_NODE);callback
(function
): The function to call with each node.
When callback return false, stops iterating.
Browser Support
Pretty much every browser (available through browserstack) runs all retext-visit unit tests.
License
MIT