mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
71.54k stars 6.48k forks source link

when declaring participants the elements are generated twice #370

Closed jorgheymans closed 7 years ago

jorgheymans commented 8 years ago

from the documentation

sequenceDiagram
    participant John
    participant Alice
    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!

using the live editor this is rendered correctly, but using the CLI i get this

image

C:\windows\system32\cmd.exe /c (mermaid tmp\test.txt -o C:\RC\tmp)
Num files to execute : 1
ready to execute png: test.txt.png
CONSOLE: [10:13:11 (182)]  Starting rendering diagrams (from line # in "")
CONSOLE: [10:13:11 (182)]  Start On Load before: undefined (from line # in "")
CONSOLE: [10:13:11 (182)]  Initializing mermaidAPI (from line # in "")
CONSOLE: [10:13:11 (182)]  Setting conf  gantt - useWidth (from line # in "")
CONSOLE: [10:13:11 (182)]  Setting config: gantt useWidth to 1200 (from line # in "")
CONSOLE: [10:13:11 (187)]  Adding message from=Alice to=John message=Hello John, how are you? type=0 (from line # in "")
CONSOLE: [10:13:11 (187)]  Adding message from=John to=Alice message=Great! type=1 (from line # in "")
CONSOLE: [10:13:11 (196)]  For line height fix Querying: #mermaidChart0 .actor-line (from line # in "")
saved png: test.txt.png
Hit any key to close this window...
kdoba22 commented 8 years ago

Has anyone figured out what is causing this issue?
I have a very similar issue with IE 11 where the SVG markup is repeated twice, but it works correctly with Chrome and Firefox.

michaelritsema commented 8 years ago

Make sure you don't have white space after the John's participant declaration. They should chop off the white space when registering it, but they don't. So when you create the edge from John, "John " is registered but not "John", so it registers a new one at the end.

jorgheymans commented 8 years ago

there is no whitespace after either participant declaration, so this is not it.

martijnschoenmakers commented 7 years ago

I have the same problem. Also since I want to activate one off the participants from the beginning, this is leading to issues (since I cannot activate a participant that is not yet created.)

Would be nice if anyone can find what is causing this.

dsschneidermann commented 7 years ago

Generated SVG is

<rect x="0" y="0" fill="#eaeaea" stroke="#666" width="150" height="65" rx="3" ry="3" class="actor" />

<text x="75" y="32.5" dominant-baseline="central" alignment-baseline="central" class="actor" style="text-anchor: middle;">

    <tspan x="75" dy="0">Example Participant

    </tspan>

</text>

So it looks like it is a line-feed problem. Switching my input file from

CRLF -> LF

fixed the issue, and I tried to write a quick string.replace fix, but can't get that to work

tylerlong commented 7 years ago

Try the latest CLI program: https://github.com/mermaidjs/mermaid.cli

Feel free to reopen if you still have this issue.