import { contentAsText } from '../helpers.js' export default async function (doc, rootLevel) { const { next, line, match, tail, level, head } = doc const node = { type: head(), variant: tail() || 'neutral', class: '', href: '', text: '' } while (await next(rootLevel)) { if (match('class')) node.class = tail() else if (match('href')) node.href = tail() else { node.text = await contentAsText(doc, rootLevel, true) } } return node }