Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.forEach((c) => {
const fileName = Object.keys(c)[0];
const filePath = path.resolve(process.cwd(), docDir, fileName);
let fileContent = fs.readFileSync(filePath, 'utf8').trim();
const fileContentArr = fileContent.split('\n');
if (/^\s*#\s*([^#].*?)\s*$/.test(fileContentArr[0])) fileContentArr.shift();
fileContent = fileContentArr.join('\n');
const HTMLContent = md.render(fileContent);
const TEXTContent = htmlToText.fromString(HTMLContent, {
wordwrap: false,
ignoreImage: true,
ignoreHref: true
});
const result = {};
result.file = fileName;
result.line = TEXTContent.split('\n').length;
result.word = wordCount(TEXTContent);
result.char = TEXTContent.length;
filesArr.push(result);
});
function markdownRender(root, optionObj) {
md.set({
tocCallback(tocMarkdown, tocArray, tocHtml) {
optionObj.toc = tocHtml;
}
});
optionObj.content = md.render(optionObj.content);
return optionObj;
}
function markdownRender(root, optionObj) {
md.set({
tocCallback(tocMarkdown, tocArray, tocHtml) {
optionObj.toc = tocHtml;
}
});
optionObj.content = md.render(optionObj.content);
return optionObj;
}