Unist node inspector.
npm:
npm install unist-util-inspectvar unified = require('unified');
var inspect = require('unist-util-inspect');
var parse = require('rehype-parse');
var tree = unified().use(parse).parse('<h2>Hello, world!</h2>');
console.log(inspect(tree));Yields:
root[1] (1:1-1:23, 0-22) [data={"quirksMode":true}]
└─ element[2] [tagName="html"]
├─ element[0] [tagName="head"]
└─ element[1] [tagName="body"]
└─ element[1] (1:1-1:23, 0-22) [tagName="h2"]
└─ text: "Hello, world!" (1:5-1:18, 4-17)
By default, color support is enabled on Node.js and turned off anywhere else. See below on how to change that.
node(Node).
string — String representing node.
Where <style> is either color or noColor.
To explicitly add or remove ANSI sequences, use either inspect.color(node)
or inspect.noColor(node).
See contribute.md in syntax-tree/unist for ways to get
started.
This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.