chore: format curriculum (#37912)

This commit is contained in:
Oliver Eyton-Williams
2020-12-15 16:52:02 +01:00
committed by GitHub
parent 45fe3d8814
commit 22fbc62f88
52 changed files with 9021 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
const stringify = require('remark-stringify');
const { root } = require('mdast-builder');
const unified = require('unified');
const getAllBetween = require('../utils/get-all-between');
const stringifyMd = nodes =>
unified()
.use(stringify, { fences: true, emphasis: '*' })
.stringify(root(nodes));
function plugin() {
return transformer;
function transformer(tree, file) {
const descriptionNodes = getAllBetween(
tree,
{ type: 'html', value: "<section id='description'>" },
{ type: 'html', value: '</section>' }
);
file.data.description = stringifyMd(descriptionNodes);
const instructionsNodes = getAllBetween(
tree,
{ type: 'html', value: "<section id='instructions'>" },
{ type: 'html', value: '</section>' }
);
file.data.instructions = stringifyMd(instructionsNodes);
}
}
module.exports = plugin;