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

when code end with space, mermaid.parse return true but mermaid.run throw error #6054

Open
fengliner opened this issue Nov 13, 2024 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@fengliner
Copy link

Description

if code end with space,run mermaid.parse(code) return true. But when run mermaid.parse({nodes: [ref.current]) throw error.

Steps to reproduce

const code = `
sequenceDiagram
    participant Alice
    participant Bob

    Alice->>Bob: 你好,Bob!
    Bob-->>Alice:
` + '  '

const html = <div ref={ref}>{code}</div>

when run mermaid.parse(code) return true. But when run mermaid.parse({nodes: [ref.current]) throw error.

when I read the source code of mermaid.run, I found that it will trim the space of code. It is the reason of the bug.

image

Screenshots

No response

Code Sample

No response

Setup

  • Mermaid version:
  • Browser and Version: [Chrome, Edge, Firefox]

Suggested Solutions

No response

Additional Context

No response

@fengliner fengliner added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 13, 2024
@fengliner fengliner changed the title mermaid.parse return true but mermaid.run thrrow error when code end with space, mermaid.parse return true but mermaid.run throw error Nov 13, 2024
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

1 participant