@@ -17,9 +17,11 @@ var green = ansiColor(32, 39)
17
17
// Define ANSII color removal functionality.
18
18
var colorExpression = / (?: (?: \u001B \[ ) | \u009B ) (?: \d { 1 , 3 } ) ? (?: (?: ; \d { 0 , 3 } ) * ) ? [ A - M | f - m ] | \u001B [ A - M ] / g
19
19
20
- // Standard keys defined by unist: https://github.com/syntax-tree/unist.
20
+ // Standard keys defined by unist (<https://github.com/syntax-tree/unist>) that
21
+ // we format differently.
21
22
// We don’t ignore `data` though.
22
- var ignore = [ 'type' , 'value' , 'children' , 'position' ]
23
+ // Also includes `name` (from xast) and `tagName` (from `hast`).
24
+ var ignore = [ 'type' , 'value' , 'children' , 'position' , 'name' , 'tagName' ]
23
25
24
26
// Inspects a node, without using color.
25
27
function noColor ( node ) {
@@ -81,12 +83,17 @@ function inspect(node) {
81
83
// Colored node formatter.
82
84
function formatNode ( node ) {
83
85
var result = [ node . type ]
86
+ var kind = node . tagName || node . name
84
87
var position = node . position || { }
85
88
var location = stringifyPosition ( position . start , position . end )
86
89
var attributes = [ ]
87
90
var key
88
91
var value
89
92
93
+ if ( kind ) {
94
+ result . push ( '<' , kind , '>' )
95
+ }
96
+
90
97
if ( node . children ) {
91
98
result . push ( dim ( '[' ) , yellow ( node . children . length ) , dim ( ']' ) )
92
99
} else if ( typeof node . value === 'string' ) {
0 commit comments