Terrace/docs/read-page/nodes/Markdown.js
2023-03-04 22:36:08 -05:00

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
}