Skip to content

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

Open
@fengliner

Description

@fengliner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageNeeds to be verified, categorized, etcType: Bug / ErrorSomething isn't working or is incorrect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions