Fix WCAG contrast, PDF export, mermaid rendering#2
Merged
lwsinclair merged 1 commit intodevelopfrom Mar 18, 2026
Merged
Conversation
…ments Contrast enforcement: - Add automatic WCAG 2.1 contrast ratio checker that runs after every mermaid render — walks all SVG text elements, computes luminance contrast against detected background, flips to black or white if ratio < 4.5:1 (AA threshold) - Detects backgrounds from parent rects/polygons (including inline styles), foreignObject backgrounds, and falls back to page canvas - Works across all themes and accent colours automatically PDF/HTML export fixes: - Fix mermaid export: use textContent instead of innerHTML for v11 compatibility (mermaid.run() reads textContent, not parsed HTML) - Add startOnLoad: false and parse() validation before run() in export - Individual diagram rendering with suppressErrors so one failure doesn't block the rest Mermaid themeVariables: - Stop overriding node text colours (primaryTextColor, nodeTextColor etc.) — let mermaid's own themes handle node contrast correctly - Only override edge label backgrounds and specific label colours Testing: - Add export e2e test: validates 28/28 mermaid diagrams render as SVGs in HTML export - Add printToPDF test: validates PDF buffer is produced - All 8 e2e tests pass (export, mermaid, launch, XSS) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
textContentvsinnerHTMLfor mermaid v11Test plan
npx playwright test test/e2e/— 8/8 tests pass🤖 Generated with Claude Code