Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions news/changelog-1.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ All changes included in 1.12:

## Formats

### All Formats

- ([#15277](https://github.com/quarto-dev/quarto-cli/pull/15277)): Fix `out-width` being ignored for Mermaid diagrams rendered as `png` or `svg` images, so wide diagrams can be fitted to the text width in Typst and PDF output. (author: @faysou)

### `pdf`

- ([#15251](https://github.com/quarto-dev/quarto-cli/pull/15251)): Fix algorithm blocks (`#alg-`) being set in italics. Their body is now upright, like definitions, examples and exercises. (author: @mcanouil)
Expand Down
10 changes: 8 additions & 2 deletions src/core/handlers/mermaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from "../svg.ts";
import {
kCellFigAlt,
kCellOutWidth,
kFigAlign,
kFigHeight,
kFigResponsive,
Expand Down Expand Up @@ -218,10 +219,15 @@ mermaid.initialize(${JSON.stringify(mermaidOpts)});
const idSpecifier = (cell.options?.label && includeCaption)
? ` #${cell.options?.label}`
: "";
const widthSpecifier = width
// out-width sets the displayed width, such as 75% of the text width,
// and drops the height so the image keeps its aspect ratio.
const outWidth = options[kCellOutWidth];
const widthSpecifier = typeof outWidth === "string"
? `width="${outWidth}"`
: width
? `width="${Math.round(width * 100) / 100}in"`
: "";
const heightSpecifier = height
const heightSpecifier = height && typeof outWidth !== "string"
? ` height="${Math.round(height * 100) / 100}in"`
: "";
const captionSpecifier = includeCaption
Expand Down
24 changes: 24 additions & 0 deletions tests/docs/smoke-all/2026/11/03/mermaid-out-width.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Mermaid out-width"
keep-typ: true
mermaid-format: png
format:
typst: default
latex: default
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
- ['image\("[^"]*mermaid-figure-1\.png", width: 50(\.0)?%\)']
- ['mermaid-figure-1\.png", height:']
latex:
ensureFileRegexMatches:
- ['\\includegraphics\[width=0\.5\\linewidth,[^\]]*\]\{[^}]*mermaid-figure-1\.png\}']
- []
---

```{mermaid}
%%| out-width: 50%
flowchart LR
A --> B
```
Loading