fix(calm-widgets): update mermaid ID handling and sanitize identifier…#1807
fix(calm-widgets): update mermaid ID handling and sanitize identifier…#1807LeighFinegold merged 5 commits intofinos:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes Mermaid diagram rendering issues by implementing proper ID sanitization and reserved word handling. The changes address conflicts with Mermaid's reserved keywords (like 'end', 'graph', 'subgraph') that were causing diagram generation failures, and improves HTML entity handling in the VS Code extension.
Key changes:
- Introduced
mermaidIdhelper function to sanitize node identifiers and prefix reserved words - Updated all Handlebars templates to use the new
mermaidIdhelper consistently - Added HTML entity decoding in the VS Code extension's Mermaid renderer
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| calm-widgets/src/widgets/block-architecture/core/utils.ts | Added mermaidId function with reserved word detection logic |
| calm-widgets/src/widget-helpers.ts | Implemented mermaidId as a Handlebars template helper |
| calm-widgets/src/widgets/block-architecture/typed-node.hbs | Updated to use mermaidId helper for all node IDs |
| calm-widgets/src/widgets/block-architecture/container.hbs | Updated to use mermaidId helper for container and node IDs |
| calm-widgets/src/widgets/block-architecture/click-links.hbs | Updated to use mermaidId helper for clickable links |
| calm-widgets/src/widgets/block-architecture/block-architecture.hbs | Updated to use mermaidId helper for nodes, edges, and highlights |
| calm-widgets/src/widgets/block-architecture/core/utils.spec.ts | Added comprehensive tests for mermaidId function |
| calm-widgets/src/widget-helpers.spec.ts | Added comprehensive tests for mermaidId template helper |
| calm-plugins/vscode/src/features/preview/webview/mermaid-renderer.ts | Added HTML entity decoding for Mermaid code blocks |
| calm-plugins/vscode/package.json | Bumped version from 0.0.8 to 0.0.9 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
calm-plugins/vscode/src/features/preview/webview/mermaid-renderer.ts
Outdated
Show resolved
Hide resolved
|
Once merged this change will need a manual publish of both the CLI (fixes for docify) and VSCode extension |
| expect(helpers.mermaidId(null)).toBe('node_empty'); | ||
| expect(helpers.mermaidId(undefined)).toBe('node_empty'); | ||
| expect(helpers.mermaidId(123)).toBe('node_empty'); | ||
| expect(helpers.mermaidId('')).toBe('node_empty'); |
There was a problem hiding this comment.
Make sense for now. I guess we need to enhance all of this to calm validate a lot of this stuff anyways for the null case.
fix(calm-widgets): update mermaid ID handling and sanitize identifier…
…s in widgets
Description
Resolves #1806
Type of Change
Affected Components
cli/)shared/)calm-widgets/)calm-hub/)calm-hub-ui/)docs/)calm-plugins/vscode/)Commit Message Format ✅
Testing
Checklist