index.js
function treeToDoc(tree) {
  if (tree.length === 0) return '';

  return tree.map((it) => {
    if (typeof it === 'object') {
      return `${'#'.repeat(it.level)} ${it.title}\n${treeToDoc(it.children)}`;
    }
    return it;
  }).join('\n');
}
function treeToDoc(tree) {
  if (tree.length === 0) return '';

  return tree.map((it) => {
    if (typeof it === 'object') {
      return `${'#'.repeat(it.level)} ${it.title}\n${treeToDoc(it.children)}`;
    }
    return it;
  }).join('\n');
}
function treeToDoc ( tree ) { if ( tree . length === 0 ) return '' ; return tree . map ( ( it ) => { if ( typeof it === 'object' ) { return ` ${ '#' . repeat ( it . level ) } ${ it . title } \n ${ treeToDoc ( it . children ) } ` ; } return it ; } ) . join ( '\n' ) ; }
convert an abstract md tree to document
convert an abstract md tree to document