Replace Beautiful Mermaid with Mermaider for server-side diagram rendering#2838
Draft
theletterf wants to merge 2 commits intomainfrom
Draft
Replace Beautiful Mermaid with Mermaider for server-side diagram rendering#2838theletterf wants to merge 2 commits intomainfrom
theletterf wants to merge 2 commits intomainfrom
Conversation
…ering Move Mermaid diagram rendering from client-side JavaScript (beautiful-mermaid npm package) to server-side C# (Mermaider NuGet package), producing inline SVGs at build time instead of shipping a JS runtime to the browser. - Add Mermaider 0.5.0 NuGet package to Elastic.Markdown - Replace RenderMermaidBlock() to call MermaidRenderer.RenderSvg() with strict mode and SVG sanitization - Emit inline SVG wrapped in mermaid-container/viewport/rendered divs - Graceful fallback with build warning on parse failures - Simplify mermaid.ts to only handle zoom/pan/fullscreen controls for pre-rendered SVGs (remove all beautiful-mermaid integration) - Remove @theletterf/beautiful-mermaid npm dependency and copy script - Update test assertions for inline SVG output Co-authored-by: Claude <noreply@anthropic.com> Made-with: Cursor
Comment on lines
+299
to
+306
| catch (Exception e) | ||
| { | ||
| block.EmitWarning($"Failed to render Mermaid diagram: {e.Message}"); | ||
| _ = renderer.Write("<pre class=\"mermaid-error\"><code>"); | ||
| _ = renderer.WriteEscape(mermaidText); | ||
| _ = renderer.Write("</code></pre>"); | ||
| return; | ||
| } |
|
|
||
| _ = renderer.WriteEscape(slice); | ||
| _ = renderer.WriteLine(); | ||
| _ = sb.AppendLine(slice.ToString()); |
Co-authored-by: Claude <noreply@anthropic.com> Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@theletterf/beautiful-mermaidnpm package) to server-side C# (Mermaider NuGet package), producing inline SVGs at build time instead of shipping a JS runtime to the browser.classDef/styledirectives) and SVG sanitization (strips XSS vectors), matching the security posture of the existing setup.mermaid.tsclient code is simplified to only attach interactive controls (zoom, pan, fullscreen) to pre-rendered SVG containers — no more lazy-loading a JS rendering library.Made with Cursor