Skip to content

Commit

Permalink
More styling
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Dec 21, 2024
1 parent 3c730f7 commit 4f23254
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/common/utils/mermaidUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@ function buildFinalCompareMarkdown(mixedLines: any[], compareMdLines, isMermaid)
if (styledLine.startsWith("|") && mixedLines.length > 1 && mixedLines[0][1] === '' && mixedLines[1][1].startsWith("|")) {
mixedLines.shift();
}
// Skip node block if there are no updated lines within
if (styledLine.startsWith("###")) {
let updatedInBlock = false;
let nextBlockPos = 0;
for (const nextLine of mixedLines) {
if (nextLine[1].startsWith("###") || nextLine[1].startsWith("_Documentation")) {
break;
}
if (nextLine[0] === "removed" || nextLine[0] === "added") {
updatedInBlock = true;
}
nextBlockPos++;
}
if (!updatedInBlock) {
const mixedLinesStartingFromNextBlock = mixedLines.slice(nextBlockPos);
// Continue processing next lines
buildFinalCompareMarkdown(mixedLinesStartingFromNextBlock, compareMdLines, isMermaid);
return;
}
}

// Tables lines
if (!isMermaid && status === "removed" && styledLine.startsWith("|")) {
Expand All @@ -173,6 +193,13 @@ function buildFinalCompareMarkdown(mixedLines: any[], compareMdLines, isMermaid)
styledLine = "|🟩" + styledLine.split("|").filter(e => e !== "").map((col: string) => `<span style="background-color: green;"><b>${col}</b></span>`).join("|") + "|";
}
// Normal lines
else if (!isMermaid && status === "removed" && styledLine.startsWith("###")) {
styledLine = `### 🟥${styledLine.replace("### ", "")}`;
}
else if (!isMermaid && status === "added" && styledLine.startsWith("###")) {
styledLine = `### 🟩${styledLine.replace("### ", "")}`;
}
// Normal lines
else if (!isMermaid && status === "removed" && styledLine !== "") {
styledLine = `<span style="background-color: red;"><i>🟥${styledLine}</i></span>`;
}
Expand Down

0 comments on commit 4f23254

Please sign in to comment.