20 lines
454 B
JavaScript
20 lines
454 B
JavaScript
import { contentAsText } from '../helpers.js'
|
|
import { parse } from 'marked'
|
|
|
|
export default async function (doc, rootNode) {
|
|
const node = {
|
|
type: rootNode.head,
|
|
class: '',
|
|
text: ''
|
|
}
|
|
|
|
let markdownText = ''
|
|
for await (const child of rootNode.children()) {
|
|
if (child.is('class')) node.class = child.tail
|
|
else markdownText += await contentAsText(child, true) + '\n'
|
|
}
|
|
node.text = parse(markdownText.trim())
|
|
|
|
return node
|
|
}
|