src/js/parse-content.js
function addNode (node, nest) {
    var obj = getHeadingObject(node)
    var level = getHeadingLevel(node)
    var array = nest
    var lastItem = getLastItem(array)
    var lastItemLevel = lastItem
      ? lastItem.headingLevel
      : 0
    var counter = level - lastItemLevel

    while (counter > 0) {
      lastItem = getLastItem(array)
      if (lastItem && lastItem.children !== undefined) {
        array = lastItem.children
      }
      counter--
    }

    if (level >= options.collapseDepth) {
      obj.isCollapsed = true
    }

    array.push(obj)
    return array
  }
function addNode (node, nest) {
    var obj = getHeadingObject(node)
    var level = getHeadingLevel(node)
    var array = nest
    var lastItem = getLastItem(array)
    var lastItemLevel = lastItem
      ? lastItem.headingLevel
      : 0
    var counter = level - lastItemLevel

    while (counter > 0) {
      lastItem = getLastItem(array)
      if (lastItem && lastItem.children !== undefined) {
        array = lastItem.children
      }
      counter--
    }

    if (level >= options.collapseDepth) {
      obj.isCollapsed = true
    }

    array.push(obj)
    return array
  }
function addNode ( node , nest ) { var obj = getHeadingObject ( node ) var level = getHeadingLevel ( node ) var array = nest var lastItem = getLastItem ( array ) var lastItemLevel = lastItem ? lastItem . headingLevel : 0 var counter = level - lastItemLevel while ( counter > 0 ) { lastItem = getLastItem ( array ) if ( lastItem && lastItem . children !== undefined ) { array = lastItem . children } counter -- } if ( level >= options . collapseDepth ) { obj . isCollapsed = true } array . push ( obj ) return array }
Add a node to the nested array.
@param {Object} node
@param {Array} nest
@return {Array}
Add a node to the nested array .