From e3760d1709f78b22609a8489cf2ebb069bce55e8 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sat, 25 Mar 2023 20:13:30 +0530 Subject: [PATCH] Fixed regex bug --- docs/config/setup/modules/mermaidAPI.md | 2 +- packages/mermaid/src/mermaidAPI.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index e942a8d6d..b94fc8b94 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -95,7 +95,7 @@ mermaid.initialize(config); #### Defined in -[mermaidAPI.ts:661](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L661) +[mermaidAPI.ts:662](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L662) ## Functions diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index da706d502..dba629477 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -399,7 +399,8 @@ const render = async function ( // clean up text CRLFs text = text.replace(/\r\n?/g, '\n'); // parser problems on CRLF ignore all CR and leave LF;; - text = text.replace(/\s*%%.*\n/gm, '\n'); // remove comments from text to avoid issues with parser + // eslint-disable-next-line unicorn/better-regex + text = text.replace(/\s*%%[^{\ninit].*\n/gm, '\n'); // remove comments from text to avoid issues with parser const idSelector = '#' + id; const iFrameID = 'i' + id;