File tree Expand file tree Collapse file tree 2 files changed +2
-12
lines changed
Expand file tree Collapse file tree 2 files changed +2
-12
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33var visit = require ( 'unist-util-visit' )
4- var modify = require ( 'unist-util-modify-children' )
54
65module . exports = compact
76
87/* Make an MDAST tree compact by merging adjacent text nodes. */
98function compact ( tree , commonmark ) {
10- var modifier = modify ( iterator )
11-
129 visit ( tree , visitor )
1310
1411 return tree
1512
16- function visitor ( node ) {
17- if ( node . children ) {
18- modifier ( node )
19- }
20- }
21-
22- function iterator ( child , index , parent ) {
23- var siblings = parent . children
13+ function visitor ( child , index , parent ) {
14+ var siblings = parent ? parent . children : [ ]
2415 var prev = index && siblings [ index - 1 ]
2516
2617 if (
Original file line number Diff line number Diff line change 1919 " index.js"
2020 ],
2121 "dependencies" : {
22- "unist-util-modify-children" : " ^1.0.0" ,
2322 "unist-util-visit" : " ^1.1.0"
2423 },
2524 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments