Skip to content

fix(state): allow colons in transition and state description text - #7430

Merged
knsv merged 4 commits into
developfrom
bug/7418_colon_in_state_transition_text
Mar 2, 2026
Merged

knsv merged 4 commits into
developfrom
bug/7418_colon_in_state_transition_text

Conversation

@knsv

@knsv knsv commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Resolves #7418

  • Modified the DESCR lexer rule in stateDiagram.jison to allow colons inside transition labels and state descriptions
  • Changed the regex from [^:\n;]+ (which excluded colons) to an alternation (?:[^:\n;]|:[^:\n;])+ that permits colons followed by non-colon characters, while preserving ::: style separator parsing
  • Added unit tests for single colon, multiple colons in transitions, and colons in state descriptions

Classification

  • Change type: Parser (JISON grammar)
  • Breaking change: No — this only allows previously-invalid input to parse correctly
  • Shared code touched: No

Verification

  • TDD: test failed before fix (3 parse errors), passes after (all 12 parser tests green)
  • Lint: passed
  • Unit tests: passed — all 93 state diagram tests pass (pnpm vitest run packages/mermaid/src/diagrams/state/)
  • Visual spot-check: verified — diagram renders correctly with colons in transition text
  • Full e2e: not run — parser-only change, no shared rendering-util/ touched
  • Changeset: generated (patch)

🤖 Generated with Claude Code

The DESCR lexer rule in stateDiagram.jison excluded colons from the
character class, causing parse errors when transition labels contained
colons (e.g. "recoverable error (ex: timeout)"). Changed the regex to
use an alternation that permits colons followed by non-colon characters,
while still preventing the `:::` style separator from being consumed.

Resolves #7418

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 409bf91

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

This PR includes changesets to release 1 package
Name Type
mermaid 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

@netlify

netlify Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 409bf91
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69a5262b6d8d1200080c2385
😎 Deploy Preview https://deploy-preview-7430--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.

@pkg-pr-new

pkg-pr-new Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@mermaid-js/examples

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

mermaid

npm i https://pkg.pr.new/mermaid@7430

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7430

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: 29f8091

@codecov

codecov Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 164 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.54%. Comparing base (6f85f2b) to head (409bf91).
⚠️ Report is 42 commits behind head on develop.

Files with missing lines Patch % Lines
scripts/verify-diagram/verify.mjs 0.00% 164 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7430      +/-   ##
==========================================
- Coverage     3.55%   3.54%   -0.02%     
==========================================
  Files          490     491       +1     
  Lines        48785   48949     +164     
  Branches       765     766       +1     
==========================================
  Hits          1734    1734              
- Misses       47051   47215     +164     
Flag Coverage Δ
unit 3.54% <0.00%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
scripts/verify-diagram/verify.mjs 0.00% <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.

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label Mar 1, 2026
Add scripts/verify-diagram/verify.mjs for visual spot-checking of
rendered diagrams during development. Uses Playwright to render a .mmd
file via the dev server and save a cropped screenshot. Auto-detects
the dev server port from .env, MERMAID_PORT env var, or defaults to
9000. Includes error handling for missing server, render failures, and
timeouts.

Add playwright as a dev dependency to support the verify script.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@argos-ci

argos-ci Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

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

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Mar 2, 2026, 6:07 AM

- Add eslint-disable no-console (CLI tool, console output is intentional)
- Add curly braces to all if-return statements
- Use RegExp#exec() instead of String#match()
- Add cspell:ignore for Playwright's networkidle API term

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@knsv
knsv marked this pull request as ready for review March 2, 2026 06:19
@knsv
knsv added this pull request to the merge queue Mar 2, 2026
Merged via the queue into develop with commit eee47fc Mar 2, 2026
29 checks passed
@knsv
knsv deleted the bug/7418_colon_in_state_transition_text branch March 2, 2026 06:31
This was referenced Mar 3, 2026
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 use :(colon) inside stateDiagram-v2 transition text

1 participant