Skip to content

Conversation

HashanCP
Copy link
Contributor

📑 Summary

Makes the flowchart elk detector less greedy. Having it without group match will detect diagram type incorrectly and will not allow to have char sequence 'graph' in any diagram type as described in #6795

Resolves #6795

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Copy link

changeset-bot bot commented Jul 27, 2025

🦋 Changeset detected

Latest commit: fb890a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
mermaid Patch
@mermaid-js/examples Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Jul 27, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit fb890a2
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6888a4e5913a880008262b65
😎 Deploy Preview https://deploy-preview-6796--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Jul 27, 2025
Copy link

pkg-pr-new bot commented Jul 27, 2025

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@6796

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@6796

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6796

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6796

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6796

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@6796

commit: fb890a2

Copy link

codecov bot commented Jul 27, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 3.71%. Comparing base (5986189) to head (fb890a2).
⚠️ Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...ges/mermaid/src/diagrams/flowchart/elk/detector.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6796   +/-   ##
=======================================
  Coverage     3.71%   3.71%           
=======================================
  Files          454     454           
  Lines        44733   44733           
  Branches       708     708           
=======================================
  Hits          1660    1660           
  Misses       43073   43073           
Flag Coverage Δ
unit 3.71% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ges/mermaid/src/diagrams/flowchart/elk/detector.ts 4.76% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

argos-ci bot commented Jul 27, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 3 added Jul 29, 2025, 10:49 AM

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regex bug in the flowchart elk detector that was causing incorrect diagram type detection when the default renderer is set to 'elk'. The greedy regex pattern was matching any text containing 'graph' anywhere, interfering with other diagram types that contain this character sequence.

  • Fixed regex pattern to use proper grouping instead of character class matching
  • Added comprehensive unit and integration tests to prevent regression
  • Ensures diagram types like mindmap, classDiagram, and erDiagram are correctly detected even when containing 'graph' in their content

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/mermaid/src/diagrams/flowchart/elk/detector.ts Fixed regex pattern from /^\s*flowchart|graph/ to /^\s*(flowchart|graph)/ for proper grouping
packages/mermaid/src/diagram-api/diagram-orchestration.spec.ts Added unit tests verifying correct diagram detection for mindmap, class, and ER diagrams
cypress/integration/rendering/mindmap.spec.ts Added integration test for mindmap with 'Photograph' label containing 'graph'
cypress/integration/rendering/erDiagram.spec.js Added integration test for ER diagram with 'Photograph' entity containing 'graph'
cypress/integration/rendering/classDiagram.spec.js Added integration test for class diagram with 'demographicProfile' property containing 'graph'

@shubhamparikh2704 shubhamparikh2704 self-requested a review July 29, 2025 10:38
@shubhamparikh2704 shubhamparikh2704 added this pull request to the merge queue Jul 30, 2025
Merged via the queue into mermaid-js:develop with commit e4b33a1 Jul 30, 2025
22 checks passed
Copy link

mermaid-bot bot commented Jul 30, 2025

@HashanCP, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

This was referenced Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to include character sequence 'graph' in node text
2 participants