20 lines
420 B
JavaScript
20 lines
420 B
JavaScript
import { contentAsText } from '../helpers.js'
|
|
import { parse } from 'marked'
|
|
|
|
export default async function (doc, rootLevel) {
|
|
const { next, line, match, tail, level, head } = doc
|
|
|
|
const node = {
|
|
type: head(),
|
|
class: '',
|
|
text: ''
|
|
}
|
|
|
|
while (await next(rootLevel)) {
|
|
if (match('class')) node.class = tail()
|
|
else node.text = parse(await contentAsText(doc, rootLevel, true))
|
|
}
|
|
|
|
return node
|
|
}
|