mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.39k stars 227 forks source link

Formatting of diagram is changed when exported to svg, pdf or png #670

Open nshern opened 6 months ago

nshern commented 6 months ago

Describe the bug When editing the mermaid diagram in the live editor it will look fine, but when exporting it to either pdf, svg or png it will look "squashed"

To Reproduce Steps to reproduce the behavior:

  1. Create a markdown file foo.md
  2. Insert the following:

    
    flowchart TD
    style A fill:#bae1FF,stroke:#000,stroke-width:2px,color:#fff
    subgraph A["`**Azure**`"]
    
    subgraph w["`**Container 🐳**`"]
    style w fill:#FFFFFF,stroke:#000,stroke-width:2px,color:#fff
    subgraph E["`**ETL-Pipeline**`"]
    style E fill:#ffb3ba,stroke:#000,stroke-width:2px,color:#fff
    direction TB
    a[("`Database`")]
    
    c["`**Transform module**
    *Transform file formats*
    *Parse out noise*`"]
        d["`**Load module**
    *Vectorize documents
    Create index
    Load into vector store*`"]
    end
    end
    
    b[(Azure Blob Storage)]
    
        a -- Extract via FTP--> c
        c -- Pass --> d
        d -- Push --> b
        backend <-- Retrieve --> b
    
    subgraph r["`**Container 🐳**

"] style r fill:#FFFFFF,stroke:#000,stroke-width:2px,color:#fff subgraph R["RAG-Application`"] style R fill:#ffffba,stroke:#000,stroke-width:2px,color:#fff

frontend["`**Frontend**

(Streamlit/Chainlit/React/other)"] backend["Backend (Python, Llamaindex, LangChain)`"] frontend <--> backend end end

subgraph q["`**Container 🐳**`"]
style q fill:#FFFFFF,stroke:#000,stroke-width:2px,color:#fff
subgraph i["`**Evaluator**`"]
style i fill:#ffdfba,stroke:#000,stroke-width:2px,color:#fff
eval["`**Evaluation module**

(Llamaindex)`"] eval -.Evaluate.-> backend end end end

subgraph S["**Local-Network**"] style S fill:#baffc9,stroke:#000,stroke-width:2px,color:#fff u("User 👤") u <-- Query --> frontend end



3. type `mmdc -i foo.md -o bar.pdf`
4. See the errror

**The same error occurs when exporting via the live editor***

**Expected behavior**
I expect that the output will look similar to how it looks in the live editor.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Before exporting**
![Screenshot 2024-03-22 at 10 22 08](https://github.com/mermaid-js/mermaid-cli/assets/90867839/be8a6261-2dc2-43b8-9d96-89e4493fe22c)

**After exporting**
![mermaid-diagram-2024-03-22-102232](https://github.com/mermaid-js/mermaid-cli/assets/90867839/a366f29c-56c3-4b93-8635-2129d8cc9c6d)

**Desktop (please complete the following information):**

- OS: MacOS Sonoma 14.4
- Browser: Brave
- Version: 123.1.64.109