feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0095583028
commit
ee1e8abd87
26
tools/formatter/add-seed-and-solution/get-challenge-text.js
Normal file
26
tools/formatter/add-seed-and-solution/get-challenge-text.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const unified = require('unified');
|
||||
const vfile = require('to-vfile');
|
||||
const markdown = require('remark-parse');
|
||||
const frontmatter = require('remark-frontmatter');
|
||||
|
||||
const textToData = require('./plugins/text-to-data');
|
||||
const testsToData = require('./plugins/tests-to-data');
|
||||
const questionToData = require('./plugins/question-to-data');
|
||||
|
||||
const textProcessor = unified()
|
||||
.use(markdown)
|
||||
.use(textToData)
|
||||
.use(testsToData)
|
||||
.use(questionToData)
|
||||
.use(frontmatter, ['yaml']);
|
||||
|
||||
exports.getText = createProcessor(textProcessor);
|
||||
|
||||
function createProcessor(processor) {
|
||||
return async msg => {
|
||||
const file = typeof msg === 'string' ? vfile.readSync(msg) : msg;
|
||||
const tree = processor.parse(file);
|
||||
await processor.run(tree, file);
|
||||
return file.data;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user