Skip to content

muraken720/unist-util-inspect

 
 

Repository files navigation

unist-util-inspect Build Status Coverage Status

Unist node inspector.

Installation

npm:

npm install unist-util-inspect

Component.js:

component install wooorm/unist-util-inspect

Bower:

bower install unist-util-inspect

Duo:

var inspect = require('wooorm/unist-util-inspect');

unist-util-inspect is also available for bower, component, duo, and for AMD, CommonJS, and globals (uncompressed and compressed).

Usage

var retext = require('retext');
var inspect = require('unist-util-inspect');

retext().use(function (cst) {
    console.log(inspect(cst));
}).process('Some simple text.');

Yields:

RootNode[1]
└─ ParagraphNode[1]
   └─ SentenceNode[6]
      ├─ WordNode[1]
      │  └─ TextNode: 'Some'
      ├─ WhiteSpaceNode[1]
      │  └─ TextNode: ' '
      ├─ WordNode[1]
      │  └─ TextNode: 'simple'
      ├─ WhiteSpaceNode[1]
      │  └─ TextNode: ' '
      ├─ WordNode[1]
      │  └─ TextNode: 'text'
      └─ PunctuationNode[1]
         └─ TextNode: '.'

API

inspect(node)

By default, color support is enabled on node and disabled 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).

License

MIT © Titus Wormer

About

Unist/retext/mdast node inspector

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%