You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rich Trott aaee43473b tools: update to ESLint 4.1.0 8 years ago
..
LICENSE doc: add eslint-plugin-markdown 8 years ago
index.js tools: update ESLint to v4.0.0 8 years ago
package.json tools: update to ESLint 4.1.0 8 years ago
readme.md tools: update ESLint to v4.0.0 8 years ago

readme.md

unist-util-visit Build Status Coverage Status

Unist node visitor. Useful when working with remark, retext, or rehype.

Installation

npm:

npm install unist-util-visit

Usage

var remark = require('remark');
var visit = require('unist-util-visit');

var tree = remark.parse('Some _emphasis_, **importance**, and `code`.');

visit(tree, 'text', visitor);

function visitor(node) {
  console.log(node);
}

Yields:

{ type: 'text', value: 'Some ' }
{ type: 'text', value: 'emphasis' }
{ type: 'text', value: ', ' }
{ type: 'text', value: 'importance' }
{ type: 'text', value: ', and ' }
{ type: 'text', value: '.' }

API

visit(node[, type], visitor[, reverse])

Visit nodes. Optionally by node type. Optionally in reverse.

Parameters
  • node (Node) — Node to search
  • type (string, optional) — Node type
  • visitor (Function) — Visitor invoked when a node is found
  • reverse (boolean, default: false) — When falsey, checking starts at the first child and continues through to later children. When truthy, this is reversed. This does not mean checking starts at the deepest node and continues on to the highest node

stop? = visitor(node, index, parent)

Invoked when a node (when type is given, matching type) is found.

Parameters
  • node (Node) — Found node
  • index (number?) — Position of node in parent
  • parent (Node?) — Parent of node
Returns

boolean? - When false, visiting is immediately stopped.

License

MIT © Titus Wormer