Skip to content

Mermaid rendering error due to line break(both "<br>" and "\n") in node content. #13481

Description

@WangJian-omo

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.1

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Mermaid flowchart rendered in neither flow-type or chat apps always failed due to the existence of line break(
, "\n") in mermaid code.

1. Error page when open the failed SVG file locally:
Error Info:

This page contains the following errors:
error on line 1 at column 8476: Opening and ending tag mismatch: br line 1 and p
Below is a rendering of the page up to the first error.

Screenshot:
https://img.picui.cn/free/2025/02/10/67a9bf2b85f7b.jpeg

2. Failed example in Chat App:
Sample code:

graph TD
    A[用户<br>开始操作] --> B[系统<br>接收请求]
    B --> C[验证<br>用户信息]
    C --> D[处理<br>请求]
    D --> E[返回<br>结果]

screenshot of failed page: https://img.picui.cn/free/2025/02/10/67a9bf2bbebd7.jpeg
screenshot of failed code: https://img.picui.cn/free/2025/02/10/67a9bf2bc93fa.jpeg

In other situations, mermaid code can rendered properly without any line break.

✔️ Expected Behavior

Mermaid code with line breaks rendered correctly.

❌ Actual Behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood first issue for newcomers🐞 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions