From 5f82e6efbdf7352c588a498d3ebd16e115ce3241 Mon Sep 17 00:00:00 2001 From: Erfan Nourbakhsh Date: Tue, 1 Oct 2024 01:03:37 -0400 Subject: [PATCH] Optimize regex for handling gradient style lookups --- .../mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts index 778a6a4b74a..860c3a57154 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts @@ -101,7 +101,7 @@ export const draw = async function (text: string, id: string, _version: string, // Look for all gradient styles, ensuring that nested parentheses due to color functions are handled properly const linearGradientStyles = vertex.cssCompiledStyles ?.join('') - ?.match(/fill\s*:\s*linear-gradient\(([^()]*(\([^()]*\))*[^()]*)+\)/g); + ?.match(/fill\s*:\s*linear-gradient\([^()]*?(?:\([^()]*?\)[^()]*)*\)/g); if (linearGradientStyles) { shapeElement.style('fill', null); // Clear any existing fill