2023-02-12 16:52:47 -05:00

27 lines
501 B
JavaScript

const knownNodes = require('./index.js')
module.exports = async function (doc, rootLevel) {
const { next, line, match, tail, level, head } = doc
const node = {
type: head(),
class: '',
children: []
}
while (await next(rootLevel)) {
if (!head()) continue
const block = head()
if (match('class')) {
node.class = tail()
continue
}
if (!knownNodes[block]) continue
node.children.push(await knownNodes[block](doc, level()))
}
return node
}