More progress on parser.
This commit is contained in:
17
docs/parser/helpers.js
Normal file
17
docs/parser/helpers.js
Normal 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')
|
||||
}
|
||||
Reference in New Issue
Block a user