I have cloned this repository material design
In the catalog folder of this project catalog, at the path of /scripts/copy-docs.mjs, the following command remove some specific comments from md files.
const transforms = [
// catalog-only code comments are removed
{
before: /<!-- catalog-only-start -->(n)*?<!--s*/gm,
after: '',
},
{
before: /s*-->(n)*?<!-- catalog-only-end -->/gm,
after: '',
},
// removes everything in between github-only-start and github-only-end
// comments
{
before: /s*<!-- no-catalog-start -->(.|n)*?<!-- no-catalog-end -->s*/gm,
after: 'nn',
},
// eleventy pages end with `/` so `components/checkbox.md` will turn into the
// url `/components/checkbox`. Thus we need to transform the relative
// `./images` links to `../images`.
{
before: /images//gm,
after: '../images/',
},
];
async function fileIncludeTransform(filepath, fileContents) {
const catalogIncludeRegex = /<!--s?catalog-include "(.+)"s?-->/g;
const matches = [];
let match = catalogIncludeRegex.exec(fileContents);
// Collect all the regex matches
while (match) {
matches.push(match);
match = catalogIncludeRegex.exec(fileContents);
}
const fileDir = dirname(filepath);
// Iterate through the regex matches backward and splice in the file contents.
// Iterating backwards so that injecting won't affect match string indices.
for (let i = matches.length - 1; i >= 0; i--) {
const match = matches[i];
const matchedString = match[0];
const includePath = match[1];
console.log(`Injecting ${includePath} file contents into ${filepath}...`);
const includeContents = await readFile(join(fileDir, includePath), 'utf8');
fileContents = fileContents.slice(0, match.index) + includeContents +
fileContents.slice(match.index + matchedString.length);
}
return fileContents;
}
async function transformReadmes(filepaths, outdir = '', replacements = []) {
const readmePromises = filepaths.map(async (entry) => {
let readme = await readFile(entry, 'utf8');
console.log(`Transforming ${entry}`);
transforms.forEach((transform) => {
readme = readme.replaceAll(transform.before, transform.after);
});
readme = await fileIncludeTransform(entry, readme);
// The `components/<component-name>.md` path.
let localPath = relative(join('..', 'docs'), entry);
for (const [pattern, replacement] of replacements) {
const regex = new RegExp(pattern);
localPath = localPath.replace(regex, replacement);
}
// The output path at
// /catalog/site/components/<?local path>/<component name>.md
const outputPath = join('site', outdir, localPath);
console.log(`Writing trasnformed file to: ${outputPath}`);
return writeFile(outputPath, readme);
});
await Promise.all(readmePromises);
}
When i build the project, these pieces of codes does not remove specific comments from found files. I have this problem in windows, not linux based systems.
How can modify this transformation in windows?