Skip to content

fix: add missing xmlns:xlink namespace for Mermaid PNG export#547

Closed
highoncomputers wants to merge 1 commit into
vercel:mainfrom
highoncomputers:fix/mermaid-png-xlink-namespace
Closed

fix: add missing xmlns:xlink namespace for Mermaid PNG export#547
highoncomputers wants to merge 1 commit into
vercel:mainfrom
highoncomputers:fix/mermaid-png-xlink-namespace

Conversation

@highoncomputers

Copy link
Copy Markdown

Mermaid SVG output sometimes uses xlink:href attributes without declaring the required xmlns:xlink namespace on the root <svg> element. When converting SVG to PNG via canvas in svgToPngBlob, browsers require valid XML and fail to load the image if the namespace is missing, causing PNG export to silently fail.

Fix: Added a normalizeSvg helper that detects xlink:href usage and injects xmlns:xlink=http://www.w3.org/1999/xlink on the root SVG element when missing.

Closes #541

Mermaid SVG output sometimes uses xlink:href attributes without
declaring the xmlns:xlink namespace on the root <svg> element. When
converting SVG to PNG via canvas, browsers require valid XML and fail
to load the image, causing the PNG export to silently fail.

Fix by detecting xlink:href usage and injecting the required namespace.

Closes #541
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@highoncomputers is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@highoncomputers highoncomputers closed this by deleting the head repository Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mermaid PNG export fails for SVGs with xlink:href because generated SVG is not XML-valid

1 participant