Skip to content

Commit

Permalink
Correcting experience name updates on the links
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekhar Sirivuri committed Apr 19, 2024
1 parent 09efdeb commit 9cddbb9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions actions/docxUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ async function updateDocument(mdPath, expName, options = {}){
await parseMarkdown(state);
const { mdast } = state.content;
updateExperienceNameFromLinks(mdast.children, expName);
console.log('All links replaced');
logger.info('Experience name removed from links');
iterateGtRowsToReplaceStyles();
console.log('All styles replaced');
logger.info('Graybox styles removed');
//generated docx file from updated mdast
const docx = await generateDocxFromMdast(mdast);
//TODO promote this docx file
console.log('Mdast to Docx file conversion done');
logger.info('Mdast to Docx file conversion done');
}
}

Expand All @@ -67,7 +67,8 @@ const updateExperienceNameFromLinks = (mdast, expName) => {
}
//remove experience name from links on the document
if (child.type === 'link' && child.url && (child.url.includes(expName) || child.url.includes(gbDomainSuffix))) {
child.url = child.url.replaceAll(expName, emptyString).replaceAll(gbDomainSuffix, emptyString);
child.url = child.url.replaceAll(`/${expName}/`, '/').replaceAll(gbDomainSuffix, emptyString);
logger.info(`Link updated: ${child.url}`);
}
if (child.children) {
updateExperienceNameFromLinks(child.children, expName);
Expand Down Expand Up @@ -97,11 +98,11 @@ const iterateGtRowsToReplaceStyles = () => {
const replaceGrayboxStyles = (node) => {
//replace all graybox styles from blocks and text
if (node && node.type === 'text' && node.value && node.value.includes(gbStyleExpression)) {
console.log(node);
logger.info(node);
node.value = node.value.replace(grayboxStylesRegex, emptyString)
.replace('()', emptyString).replace(', )', ')');
console.log('updated value>> ');
console.log(node);
logger.info('updated value>> ');
logger.info(node);
return;
}
if (node.children) {
Expand Down

0 comments on commit 9cddbb9

Please sign in to comment.