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