dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
25 lines
717 B
JavaScript
25 lines
717 B
JavaScript
const { getSection } = require('./utils/get-section');
|
|
|
|
const { createMdastToHtml } = require('./utils/i18n-stringify');
|
|
const { splitOnThematicBreak } = require('./utils/split-on-thematic-break');
|
|
|
|
function plugin() {
|
|
return transformer;
|
|
|
|
function transformer(tree, file) {
|
|
const toHtml = createMdastToHtml(file.data.lang);
|
|
const assignmentNodes = getSection(tree, '--assignment--');
|
|
|
|
function getAssignments(assignmentNodes) {
|
|
const assignmentGroups = splitOnThematicBreak(assignmentNodes);
|
|
return assignmentGroups.map(assignment => toHtml(assignment));
|
|
}
|
|
|
|
file.data.assignments = getAssignments(assignmentNodes).filter(
|
|
a => a != ''
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = plugin;
|