parse5-traverse
v1.0.3
Published
simple but flexible parse5 AST traversal with pre and post visitors
Downloads
6,753
Maintainers
Readme
parse5-traverse
Simple but flexible AST traversal with pre and post visitors. The main code of this project comes from ast-traverse. As ast-traverse
is not compatible with parse5, parse5-traverse
got created.
Getting started
$ npm install --save parse5-traverse
Usage
const parse5 = require('parse5');
const traverse = require('parse5-traverse');
const documentFragment = parse5.parseFragment('<table></table>');
// print AST node types, pre-order (node first, then its children)
traverse(ast, {
pre(node, parent) {
// node -> the current node
// parent -> the parent node
}
post(node, parent) {
}
});