More progress on parser.

This commit is contained in:
Joshua Bemenderfer
2023-02-12 09:00:19 -05:00
parent bc2fc78c96
commit 4e10b07561
9 changed files with 93 additions and 31 deletions

17
docs/parser/helpers.js Normal file
View File

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