@@ -17,9 +17,11 @@ var green = ansiColor(32, 39)
1717// Define ANSII color removal functionality.
1818var colorExpression = / (?: (?: \u001B \[ ) | \u009B ) (?: \d { 1 , 3 } ) ? (?: (?: ; \d { 0 , 3 } ) * ) ? [ A - M | f - m ] | \u001B [ A - M ] / g
1919
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.
2122// 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' ]
2325
2426// Inspects a node, without using color.
2527function noColor ( node ) {
@@ -81,12 +83,17 @@ function inspect(node) {
8183 // Colored node formatter.
8284 function formatNode ( node ) {
8385 var result = [ node . type ]
86+ var kind = node . tagName || node . name
8487 var position = node . position || { }
8588 var location = stringifyPosition ( position . start , position . end )
8689 var attributes = [ ]
8790 var key
8891 var value
8992
93+ if ( kind ) {
94+ result . push ( '<' , kind , '>' )
95+ }
96+
9097 if ( node . children ) {
9198 result . push ( dim ( '[' ) , yellow ( node . children . length ) , dim ( ']' ) )
9299 } else if ( typeof node . value === 'string' ) {
0 commit comments