Terrace/docs/parser/nodes/Header.js
2023-02-12 22:11:13 -05:00

17 lines
341 B
JavaScript

module.exports = async function (doc, rootLevel) {
const { next, line, match, tail, level, head } = doc
const node = {
type: head(),
level: tail().split(' ')[0],
text: tail().split(' ').slice(1).join(' '),
class: ''
}
while (await next(rootLevel)) {
if (match('class')) node.class = tail()
}
return node
}