deepwiki-open icon indicating copy to clipboard operation
deepwiki-open copied to clipboard

bug: Mermaid diagram rendering fails on Architecture Overview page

Open lvy010 opened this issue 10 months ago • 3 comments

Bug Description

The Mermaid diagram in the "Architecture Overview" section fails to render, showing error:

Syntax error in text
mermaid version 10.9.1

Steps to Reproduce

  1. Go to Documentation → Introduction to DeepWiki-Open
  2. Scroll to "Architecture Overview" section
  3. Observe diagram rendering error

Expected Behavior

The system architecture diagram should render correctly

Screenshots

Image

Environment

  • Page: Architecture Overview
  • Mermaid Version: 10.9.1

Possible Cause

  • Invalid Mermaid syntax
  • Version compatibility issue
  • Special character encoding problem

lvy010 avatar Jan 05 '26 07:01 lvy010

I've created a solution: https://github.com/lvy010/mermaid-validator

This is an npm package for validating Mermaid syntax and providing better error handling.

Planning to publish to npm tomorrow after testing, then submit a PR to fix this issue.

Welcome to review

lvy010 avatar Jan 07 '26 11:01 lvy010

One concrete cause I hit on generated wikis (local Ollama, qwen3-coder:30b): the model writes node labels with parentheses inside square brackets, which Mermaid rejects unless the label is quoted:

graph TD
    A[Frontend (Next.js)] --> B[API Layer (Express)]

Quoting fixes it: A["Frontend (Next.js)"] --> B["API Layer (Express)"]. In one 21-page wiki, 6 labels had this problem.

The diagram rules in api/services/wiki/prompts.py don't mention quoting. Two possible fixes:

  1. Add a prompt rule such as: "Wrap any node label containing (, ), [, ], {, }, : or , in double quotes, e.g. A["Frontend (Next.js)"]."
  2. Quote such labels before rendering in Mermaid.tsx, as a safety net for existing cached wikis.

Happy to open a PR for either if that would help.

ieCecchetti avatar Oct 12 '26 11:10 ieCecchetti