Skip to content

Commit

Permalink
refacto + font color black
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Dec 30, 2024
1 parent a1cbd92 commit 47681d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/common/gitProvider/utilsMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ export async function flowDiffToMarkdownForPullRequest(flowNames: string[], from
const fileMetadata = await MetadataUtils.findMetaFileFromTypeAndName("Flow", flowName);
try {
if (supportsMermaidInPrMarkdown) {
await generateMarkdownWithMermaid(fileMetadata, fromCommit, toCommit, flowDiffMarkdownList, flowName);
await generateDiffMarkdownWithMermaid(fileMetadata, fromCommit, toCommit, flowDiffMarkdownList, flowName);
}
else {
await generateMarkdownWithSvg(fileMetadata, fromCommit, toCommit, flowDiffMarkdownList, flowName);
await generateDiffMarkdownWithSvg(fileMetadata, fromCommit, toCommit, flowDiffMarkdownList, flowName);
}
} catch (e: any) {
uxLog(this, c.yellow(`[FlowGitDiff] Unable to generate Flow diff: ${e.message}`));
Expand All @@ -108,15 +108,15 @@ Error while generating Flows visual git diff
}
}

async function generateMarkdownWithMermaid(fileMetadata: string | null, fromCommit: string, toCommit: string, flowDiffMarkdownList: any, flowName: string) {
async function generateDiffMarkdownWithMermaid(fileMetadata: string | null, fromCommit: string, toCommit: string, flowDiffMarkdownList: any, flowName: string) {
const { outputDiffMdFile } = await generateFlowVisualGitDiff(fileMetadata, fromCommit, toCommit, { mermaidMd: true, svgMd: false, debug: false });
if (outputDiffMdFile) {
const flowDiffMarkdownMermaid = await fs.readFile(outputDiffMdFile.replace(".md", ".mermaid.md"), "utf8");
flowDiffMarkdownList.push({ name: flowName, markdown: flowDiffMarkdownMermaid });
}
}

async function generateMarkdownWithSvg(fileMetadata: string | null, fromCommit: string, toCommit: string, flowDiffMarkdownList: any, flowName: string) {
async function generateDiffMarkdownWithSvg(fileMetadata: string | null, fromCommit: string, toCommit: string, flowDiffMarkdownList: any, flowName: string) {
const { outputDiffMdFile } = await generateFlowVisualGitDiff(fileMetadata, fromCommit, toCommit, { mermaidMd: true, svgMd: true, debug: false });
flowDiffMarkdownList.push({ name: flowName, markdown: outputDiffMdFile });
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/utils/mermaidUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ function buildFinalCompareMarkdown(mixedLines: any[], compareMdLines, isMermaid,

// Tables lines
if (!isMermaid && status === "removed" && styledLine.startsWith("|") && !styledLine.startsWith("|:-")) {
styledLine = "|🟥" + styledLine.split("|").filter(e => e !== "").map((col: string) => `<span style="background-color: #ff7f7f;"><i>${col}</i></span>`).join("|") + "|";
styledLine = "|🟥" + styledLine.split("|").filter(e => e !== "").map((col: string) => `<span style="background-color: #ff7f7f; color: black;"><i>${col}</i></span>`).join("|") + "|";
}
else if (!isMermaid && status === "added" && styledLine.startsWith("|") && !styledLine.startsWith("|:-")) {
styledLine = "|🟩" + styledLine.split("|").filter(e => e !== "").map((col: string) => `<span style="background-color: #a6e22e;"><b>${col}</b></span>`).join("|") + "|";
styledLine = "|🟩" + styledLine.split("|").filter(e => e !== "").map((col: string) => `<span style="background-color: #a6e22e; color: black;"><b>${col}</b></span>`).join("|") + "|";
}
// Normal lines header 3
else if (!isMermaid && status === "removed" && styledLine.startsWith("#### ")) {
Expand All @@ -387,10 +387,10 @@ function buildFinalCompareMarkdown(mixedLines: any[], compareMdLines, isMermaid,
}
// Normal lines
else if (!isMermaid && status === "removed" && styledLine !== "" && !styledLine.startsWith("|:-") && !styledLine.startsWith("___")) {
styledLine = `<span style="background-color: #ff7f7f;"><i>🟥${styledLine}</i></span>`;
styledLine = `<span style="background-color: #ff7f7f; color: black;"><i>🟥${styledLine}</i></span>`;
}
else if (!isMermaid && status === "added" && styledLine !== "" && !styledLine.startsWith("|:-") && !styledLine.startsWith("___")) {
styledLine = `<span style="background-color: #a6e22e;"><b>🟩${styledLine}</b></span>`;
styledLine = `<span style="background-color: #a6e22e; color: black;"><b>🟩${styledLine}</b></span>`;
}
// Boxes lines
else if (isMermaid === true && status === "removed" && currentLine.split(":::").length === 2) {
Expand Down

0 comments on commit 47681d6

Please sign in to comment.