Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect connection when a tree node's id is the single letter "o" #6313

Open
boboboneX opened this issue Feb 23, 2025 · 1 comment
Open
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@boboboneX
Copy link

Description

If a node's id is named as "o", while having two links leaving this node "o" and points to two other links, i.e.,

        o
       / \
     /     \
    p       k

The rendered result has incorrect connections among nodes o, p, and k. The result is like

 o
 |
 p
 |
 k

Steps to reproduce

  1. Follow the minimal example:
graph TD;
    o[o]
    o-->p
    o-->k
  1. Check the rendered result
  2. Replace the node id "o" with other choices, e.g., "o1", and check the result again.

Screenshots

Expected corrected result:

Image

The incorrect result rendered:

Image

Code Sample

graph TD;
    o[o]
    o-->p
    o-->k

Setup

  • Mermaid version: 11.4.1
  • Browser and Version: Chrome 133.0.6943.127

Suggested Solutions

  • Fix the "o"-id bug, or
  • Warn that the letter "o" should not be used as a node ID.

Additional Context

No response

@boboboneX boboboneX added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Feb 23, 2025
@BambioGaming
Copy link

Possible Fix for Issue Using "o" as Node ID

Hello. The issue you are facing can be resolved using instructions from the Mermaid documentation. Based on the documentation, if you are using "o" or "x" as the first letter in a node ID, Mermaid may misinterpret it as a special edge type rather than a node identifier.

Solution

To fix this issue, try one of the following approaches:

  1. Add a space before the node ID
graph TD
A--- oB
A--- xB
  1. Capitalize the first letter of the node ID
graph TD
A--- OB
A--- XB

In your case, instead of doing this:

Image

You can do this:

Image

Here, the letter o is capitalized

Possible Causes of the Issue

  • Mermaid interprets o as a circle edge and x as a cross edge, so nodes starting with these letters may not be treated as valid nodes.
  • If "o" or "x" is used at the start of a node ID without spacing or capitalization, Mermaid may fail to render the graph properly.

This behavior is documented in the Mermaid syntax guide, as shown in the attached image.

Image

Let me know if this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants