Skip to content

syntax-tree/unist-util-inspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

unist-util-inspect Build Status Coverage Status

Unist node inspector.

Installation

npm:

npm install unist-util-inspect

Usage

var 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)

API

inspect(node)

By default, color support is enabled on Node.js and turned off anywhere else. See below on how to change that.

Parameters
Returns

string — String representing node.

inspect.<style>[.<style>...](node)

Where <style> is either color or noColor.

To explicitly add or remove ANSI sequences, use either inspect.color(node) or inspect.noColor(node).

Contribute

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.

License

MIT © Titus Wormer

Contributors 6