Skip to content

fix(mindmap): decode <, >, and & characters in node labels - #6414

Closed
nour0205 wants to merge 1 commit into
mermaid-js:developfrom
nour0205:fix/mindmap-escape-lt
Closed

nour0205 wants to merge 1 commit into
mermaid-js:developfrom
nour0205:fix/mindmap-escape-lt

Conversation

@nour0205

Copy link
Copy Markdown
Member

📑 Summary

This PR fixes issue #6396 by decoding the characters <, > and & that were incorrectly rendered as &lt;, &gt;, and &amp; in mindmap node labels.

Resolves #6396

📏 Design Decisions

  • Used the existing decodeEntities() function to decode text when rendering tspan elements in createText.ts.

Verified manually in the dev environment with the following:

mermaid
mindmap
  root((Symbols))
    LessThan["A < B"]
    GreaterThan["A > B"]
    Amp["A & B"]

screenshots :
image
image

📋 Tasks

Make sure you

  • [x ] 📖 have read the contribution guidelines
  • [ x] 💻 have added necessary unit/e2e tests.
  • [x ] 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • [x ] 🦋 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:.

@changeset-bot

changeset-bot Bot commented Mar 25, 2025 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 68ae03e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label Mar 25, 2025
@netlify

netlify Bot commented Mar 25, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 68ae03e
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67e4321b1995d70008180fc8
😎 Deploy Preview https://deploy-preview-6414--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 site configuration.

@pkg-pr-new

pkg-pr-new Bot commented Mar 25, 2025 •

Copy link
Copy Markdown

Open in Stackblitz

npm i https://pkg.pr.new/mermaid-js/mermaid@6414
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6414
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6414
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6414

commit: 68ae03e

@codecov

codecov Bot commented Mar 25, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 3.86%. Comparing base (936d107) to head (dcc3b46).

Files with missing lines Patch % Lines
packages/mermaid/src/utils.ts 0.00% 7 Missing ⚠️
packages/mermaid/src/rendering-util/createText.ts 0.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #6414      +/-   ##
==========================================
- Coverage     3.86%   3.86%   -0.01%     
==========================================
  Files          412     412              
  Lines        43189   43197       +8     
  Branches       664     664              
==========================================
  Hits          1670    1670              
- Misses       41519   41527       +8     
Flag Coverage Δ
unit 3.86% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
packages/mermaid/src/rendering-util/createText.ts 0.49% <0.00%> (-0.01%) ⬇️
packages/mermaid/src/utils.ts 17.89% <0.00%> (-0.20%) ⬇️
🚀 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.

@argos-ci

argos-ci Bot commented Mar 25, 2025 •

Copy link
Copy Markdown

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

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 114 changed Mar 26, 2025, 5:07 PM

@nour0205
nour0205 force-pushed the fix/mindmap-escape-lt branch from dcc3b46 to 68ae03e Compare March 26, 2025 16:58
@knsv

knsv commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

[sisyphus-bot] Thank you for tackling this, @nour0205! After comparing both PRs, we found that #6406 (filed 3 days earlier) contains the same fix with an identical diff. We're going with that one on a first-come-first-served basis.

Appreciate the effort — and you've got plenty of other great contributions in flight!

@knsv-bot

knsv-bot commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

[sisyphus-bot]

Hi @nour0205 — thanks for the fix for decoding <, >, and & in mindmap nodes, and sorry for the slow follow-up.

While comparing PRs we found that #6406 (filed a few days earlier) contains essentially the same fix, so we're closing this as a duplicate to consolidate the work there. Your diagnosis was spot on.

If you spot something your version handles that #6406 doesn't, please reopen or comment. Thank you for the contribution!

@knsv-bot knsv-bot closed this Jun 4, 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.

Incorrect Rendering of < in Mindmap

3 participants