Fix Mermaid shape, relationship, and state description parsing (#48489)

## What changed

- Reject unsupported flowchart shapes and Markdown strings so the terminal renderer preserves the source with an unsupported-feature notice instead of misrendering it. Keep ordinary quoted labels containing shape-like punctuation valid.
- Preserve class relationship targets beginning with `o`, such as `A --orange`, instead of consuming the first letter as an aggregation marker.
- Accumulate state aliases and descriptions in source order: use the first as the title and subsequent entries as body rows, preserving state identity and limiting body rows to 16.

## Testing

Add parser regressions for these cases and description limits, update class and state snapshots, and extend TUI snapshots to verify source preservation for unsupported flowchart syntax.

GitOrigin-RevId: c44d954312c77229a3752a0d9ada14e34a43a376
This commit is contained in:
Eric Traut
2026-09-26 17:26:07 +00:00
committed by copyberry
parent 1a89aec960
commit 6e1ab4d294
9 changed files with 151 additions and 18 deletions
@@ -112,6 +112,16 @@ fn mermaid_fallback_notices_preserve_source() {
for (name, source, width) in [
("invalid", "```mermaid\nflowchart LR\nA[unfinished\n```", 80),
("unsupported", "```mermaid\npie\n\"Cats\": 2\n```", 80),
(
"unsupported shape after supported edges",
"```mermaid\nflowchart TD\nP --> Q\nA[(Database)]\n```",
80,
),
(
"Markdown string after supported edges",
"```mermaid\nflowchart TD\nP --> Q\nA[\"`hello **world**`\"]\n```",
80,
),
(
"too wide",
"```mermaid\nflowchart LR\nA[Request] --> B[Reply]\n```",
@@ -16,6 +16,22 @@ pie
---
unsupported shape after supported edges
This Mermaid diagram uses features the terminal renderer doesn't support.
flowchart TD
P --> Q
A[(Database)]
---
Markdown string after supported edges
This Mermaid diagram uses features the terminal renderer doesn't support.
flowchart TD
P --> Q
A["`hello **world**`"]
---
too wide
This
Mermaid