import { contentAsText } from '../helpers.js' const languages = ['terrace', 'json', 'yaml', 'toml', 'javascript', 'typescript', 'c', 'python', 'sh'] export default async (doc, rootLevel) => { const { next, level, line, head, tail, match } = doc const node = { type: head(), class: '', summaryClass: 'mb-[400px]', preClass: 'max-h-[400px]', examples: [] } while (await next(rootLevel)) { if (match('class')) node.class = tail() if (match('summary-class')) node.summaryClass = tail() if (match('pre-class')) node.preClass = tail() const exampleLevel = level() if (languages.includes(head())) { node.examples.push({ language: head(), name: tail() || '', code: (await contentAsText(doc, exampleLevel)).trimEnd('\n') }) } } return node }