diff --git a/packages/mermaid-flowchart-elk/src/detector.spec.ts b/packages/mermaid-flowchart-elk/src/detector.spec.ts index 6e949c57b9..94ac22d260 100644 --- a/packages/mermaid-flowchart-elk/src/detector.spec.ts +++ b/packages/mermaid-flowchart-elk/src/detector.spec.ts @@ -39,6 +39,26 @@ describe('flowchart-elk detector', () => { ).toBe(true); }); + // The error from the issue was reproduced with mindmap, so this is just an example + // what matters is the keyword somewhere inside graph definition + it('should check only the beginning of the line in search of keywords', () => { + expect( + detector('mindmap ["Descendant node in flowchart"]', { + flowchart: { + defaultRenderer: 'elk', + }, + }) + ).toBe(false); + + expect( + detector('mindmap ["Descendant node in graph"]', { + flowchart: { + defaultRenderer: 'elk', + }, + }) + ).toBe(false); + }); + it('should detect flowchart-elk', () => { expect(detector('flowchart-elk')).toBe(true); }); diff --git a/packages/mermaid-flowchart-elk/src/detector.ts b/packages/mermaid-flowchart-elk/src/detector.ts index 52fb355a55..3b168bd616 100644 --- a/packages/mermaid-flowchart-elk/src/detector.ts +++ b/packages/mermaid-flowchart-elk/src/detector.ts @@ -11,7 +11,7 @@ const detector: DiagramDetector = (txt, config): boolean => { // If diagram explicitly states flowchart-elk /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk - (/^\s*flowchart|graph/.test(txt) && config?.flowchart?.defaultRenderer === 'elk') + (/^\s*(flowchart|graph)/.test(txt) && config?.flowchart?.defaultRenderer === 'elk') ) { return true; }