Repository navigation
Conversation
Mermaid diagrams rendered as png or svg images always got a width and height in inches from their natural size, so out-width was ignored. In Typst and LaTeX output, wide diagrams ran past the page with no way to fit them to the text width. When out-width is set, the figure link now uses it as the image width and drops the height so the image keeps its aspect ratio. A percentage such as 50% becomes 50% of the text width in Typst and 0.5\linewidth in LaTeX.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Description
Mermaid diagrams rendered as
pngorsvgimages ignoreout-width. The Mermaid handler always writes the natural size in inches, such as{width="8.91in" height="3.02in"}, so in Typst and PDF output a wide diagram runs past the page and there is no way to fit it to the text width.When
out-widthis set, the figure link now uses it as the image width and drops the height, so the image keeps its aspect ratio.50%becomeswidth: 50.0%in Typst and0.5\linewidthin LaTeX. Withoutout-width, the output does not change.This is separate from #15192:
out-widthis relative to the text width, whilemermaid-scalethere is relative to each diagram's natural size.Tests
tests/docs/smoke-all/2026/11/03/mermaid-out-width.qmdrenders a diagram without-width: 50%to Typst and LaTeX and checks the image width in the.typand.tex. Both checks fail without the change.Checklist
I have (if applicable):