Skip to content

fix(architecture): allow non-ASCII characters and punctuation in unqu… - #7984

Merged
pbrolin47 merged 1 commit into
mermaid-js:developfrom
aloktomarr:fix/architecture-unicode-titles-7961
Jul 23, 2026
Merged

pbrolin47 merged 1 commit into
mermaid-js:developfrom
aloktomarr:fix/architecture-unicode-titles-7961

Conversation

@aloktomarr

@aloktomarr aloktomarr commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

architecture-beta bracket titles only accepted [a-zA-Z0-9_ ], so Chinese,
Cyrillic, accented Latin characters and common punctuation (-, +, ,, :, /)
caused lexer errors. Other diagram types (e.g. flowchart) already handle Unicode.

Root cause

The ARCH_TITLE terminal's unquoted alternative used \w, which without the u
flag is ASCII-only. Fixed by accepting any character except square brackets and
line breaks ([^\[\]\r\n]+). Quoted titles and previously-valid labels are unchanged.

Tests

Added parser tests for non-ASCII (Chinese, Cyrillic, accented) and punctuated
titles for both service and group. Full parser suite passes (293 tests).

Fixes #7961

Summary

  • Updated ARCH_TITLE parsing for architecture-beta diagrams to accept non-ASCII characters and punctuation in unquoted bracket titles.
  • Preserved existing quoted-title syntax and previously valid labels.
  • Added parser tests covering Chinese, Japanese, Cyrillic, accented Latin, and punctuation.
  • Added a changeset documenting the fix for #7961.

…oted titles

The ARCH_TITLE terminal's unquoted alternative used the \w character class (ASCII-only without the u flag), so Chinese, Cyrillic, accented Latin characters and punctuation like - + , : / triggered lexer errors. It now accepts any character except square brackets and line breaks, so these titles parse correctly. Quoted titles and previously-valid labels are unchanged.

Fixes mermaid-js#7961
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e848423

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

This PR includes changesets to release 1 package
Name Type
@mermaid-js/parser 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 Jul 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit e848423
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6a6096d7f87f4d0008be049c
😎 Deploy Preview https://deploy-preview-7984--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The architecture parser now accepts unquoted bracket titles containing Unicode characters and punctuation while preserving quoted-title behavior. Tests verify service and group titles, and the changeset documents the updated parsing rule.

Changes

Architecture title parsing

Layer / File(s) Summary
Title token and parser coverage
packages/parser/src/language/architecture/arch.langium, packages/parser/tests/architecture.test.ts, .changeset/architecture-unicode-titles.md
ARCH_TITLE now matches content other than brackets and line breaks. Tests verify preservation of Unicode and punctuation in service and group titles, and the changeset documents the change.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, root cause, tests, and issue link, but it misses the template's Summary, Design Decisions, and Tasks sections. Add the required Summary and Design Decisions sections, plus the Tasks checklist entries for tests, docs, and changeset as in the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests match #7961 by allowing non-ASCII and punctuation in architecture bracket labels without changing other diagram types.
Out of Scope Changes check ✅ Passed The changes are scoped to the parser fix, tests, and required changeset, with no unrelated code introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly matches the main change: architecture bracket titles now allow non-ASCII characters and punctuation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label Jul 22, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: e848423

@argos-ci

argos-ci Bot commented Jul 22, 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 - Jul 22, 2026, 10:32 AM

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.53%. Comparing base (f0ffb41) to head (e848423).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #7984      +/-   ##
===========================================
+ Coverage    77.46%   77.53%   +0.06%     
===========================================
  Files          564      564              
  Lines        74906    74906              
  Branches     12661    12661              
===========================================
+ Hits         58026    58076      +50     
+ Misses       15881    15830      -51     
- Partials       999     1000       +1     
Flag Coverage Δ
e2e 70.75% <ø> (+0.22%) ⬆️
unit 74.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 6 files with indirect coverage changes

🚀 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.

@pbrolin47

Copy link
Copy Markdown
Collaborator

Hi @aloktomarr

  1. Run the parser test and all 293 tests passed.

  2. Some feedback from review:
    [sisyphos-bot]


What's working well

🎉 The grammar fix is correct and minimal — [\w ]+ → [^\[\]\r\n]+ is exactly the right change. Switching from an allow-list to a deny-list for brackets and line-breaks is the canonical way to
support Unicode in lexer terminals without Unicode flags.

🎉 The test suite covers a great variety: Chinese (采集器), Cyrillic (Сервер), accented Latin (Café), and the specific punctuation characters reported in the issue (-, +, ,, :, /). Both service and
group titles are exercised.

🎉 Changeset is correctly typed (patch on @mermaid-js/parser) with a clear description that names the root cause.


  1. Tests passing in CI, so I'll approve

@pbrolin47
pbrolin47 added this pull request to the merge queue Jul 23, 2026
Merged via the queue into mermaid-js:develop with commit 56219a3 Jul 23, 2026
31 checks passed
@mermaid-bot

mermaid-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

@aloktomarr, 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.

@github-actions github-actions Bot mentioned this pull request Aug 18, 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.

architecture-beta: bracket labels reject non-ASCII characters (Chinese, Cyrillic, etc.)

2 participants