module.exports.contentAsText = async function(doc, rootLevel) { const { level, next, line, head } = doc const linesAsArray = [] let contentDepth = -1 while(await next(rootLevel)) { if (contentDepth === -1 && !!line()) contentDepth = level() const indent = ''.padStart(level() - contentDepth, ' ') linesAsArray.push(indent + line()) } return linesAsArray.join('\n') }