2023-03-04 22:36:08 -05:00

27 lines
512 B
JavaScript

import knownNodes from './index.js'
export default async function (doc, rootLevel, ...args) {
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(), ...args))
}
return node
}