Skip to content

Commit 8e122a1

Browse files
committed
feat(mermaid): comprehensive mermaid diagram rendering improvements
Complete overhaul of Mermaid diagram rendering system with fixes for flowcharts, sequence diagrams, bar/XY charts, and mind maps. Flowchart Rendering: 1. Intelligent edge routing with obstacle avoidance - Vertical alignment detection with offset L-shaped routing - Orthogonal routing for complex cases - Crossing minimization and coordinate optimization 2. Adaptive node spacing based on complexity - MermaidGraphAnalyzer calculates graph metrics - Dynamic width/height adjustments prevent overlaps 3. Fixed height clipping for large diagrams 4. Cycle and disconnected node handling Sequence Diagrams: - Fixed arrow syntax parsing by reordering pattern matching - Check longer patterns first (-->> before ->>) to prevent substring false matches Bar and XY Charts: 1. Added 'series' keyword support for data parsing 2. Implemented space-separated category parsing for x-axis 3. Auto-detection of format (values vs coordinate pairs) 4. Backward compatibility with legacy format Mind Maps: - Implemented indentation normalization to handle markdown code block indentation, enabling correct hierarchy parsing for full tree display Files Changed: - FlowchartRenderer.swift: Complete routing system overhaul - MermaidGraphAnalyzer.swift: New graph analysis utilities - MermaidParser.swift: Parser fixes for all diagram types - MermaidDiagramView.swift: Integration improvements Testing: - All diagram types from mermaid.txt render correctly - Flowchart edge routing handles complex topologies - Sequence diagrams parse all arrow types - Bar/XY charts display series data - Mind maps show full hierarchy Impact: Mermaid diagrams now render reliably in SAM with proper layout, routing, and data parsing across all supported diagram types.
1 parent d46b93d commit 8e122a1

4 files changed

Lines changed: 1182 additions & 190 deletions

File tree

0 commit comments

Comments
 (0)