* feat: add script to annotate challenges for translation * fix: readdirp-walk -> readdirp * fix: remove notranslate for frontmatter * fix: don't output seed/solution * feat: convert to function Also puts in some missing 'async's to make it clearer what returns promises. * refactor: use meaningful names * refactor: remove comments * chore: update dependencies * chore: move dir * fix(crowdin): annotate individual answers
27 lines
849 B
JavaScript
27 lines
849 B
JavaScript
const stringify = require('remark-stringify');
|
|
const { root } = require('mdast-builder');
|
|
const unified = require('unified');
|
|
const getAllBetween = require('../../../challenge-md-parser/mdx/plugins/utils/between-headings');
|
|
|
|
const stringifyMd = nodes =>
|
|
unified()
|
|
.use(stringify, { fences: true, emphasis: '*' })
|
|
.stringify(root(nodes));
|
|
|
|
// NOTE: we need a new plugin (rather than using the challenge parser's plugin)
|
|
// simply because it adds html to the descriptions. It's easier to start from
|
|
// scratch.
|
|
function plugin() {
|
|
return transformer;
|
|
|
|
function transformer(tree, file) {
|
|
file.data.description = stringifyMd(getAllBetween(tree, '--description--'));
|
|
file.data.instructions = stringifyMd(
|
|
getAllBetween(tree, '--instructions--')
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = plugin;
|
|
module.exports.stringifyMd = stringifyMd;
|