22 lines
503 B
JavaScript
22 lines
503 B
JavaScript
const { contentAsText } = require('../helpers')
|
|
|
|
const languages = ['terrace', 'json', 'yaml', 'toml', 'javascript', 'typescript', 'c', 'python']
|
|
|
|
module.exports = async (doc, rootLevel) => {
|
|
const { next, level, line, head, tail } = doc
|
|
|
|
const node = {
|
|
type: head(),
|
|
languages: {}
|
|
}
|
|
|
|
while (await next(rootLevel)) {
|
|
const languageLevel = level()
|
|
if (languages.includes(head())) {
|
|
node.languages[head()] = await contentAsText(doc, languageLevel)
|
|
}
|
|
}
|
|
|
|
return node
|
|
}
|