diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-07 16:13:24 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-10-15 15:06:36 +0200 |
| commit | 5220f362a5efd1a9b972cc500cd6b5c1cab4d2f2 (patch) | |
| tree | 00897c48a542d54937af5d567472c09f56a383bf | |
| parent | 60bd92eec6edb1ae2a3a7338a01bc4b6a092c0f5 (diff) | |
Error for parent-scoped figures without placement (#5151)
| -rw-r--r-- | crates/typst/src/model/figure.rs | 6 | ||||
| -rw-r--r-- | tests/suite/model/figure.typ | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/crates/typst/src/model/figure.rs b/crates/typst/src/model/figure.rs index 00a9aafd..1d3c9c95 100644 --- a/crates/typst/src/model/figure.rs +++ b/crates/typst/src/model/figure.rs @@ -351,6 +351,12 @@ impl Show for Packed<FigureElem> { .with_float(true) .pack() .spanned(self.span()); + } else if self.scope(styles) == PlacementScope::Parent { + bail!( + self.span(), + "parent-scoped placement is only available for floating figures"; + hint: "you can enable floating placement with `figure(placement: auto, ..)`" + ); } Ok(realized) diff --git a/tests/suite/model/figure.typ b/tests/suite/model/figure.typ index feaf8d3b..fbd0ab29 100644 --- a/tests/suite/model/figure.typ +++ b/tests/suite/model/figure.typ @@ -77,6 +77,11 @@ We can clearly see that @fig-cylinder and #lines(15) +--- figure-scope-without-placement --- +// Error: 2-27 parent-scoped placement is only available for floating figures +// Hint: 2-27 you can enable floating placement with `figure(placement: auto, ..)` +#figure(scope: "parent")[] + --- figure-theorem --- // Testing show rules with figures with a simple theorem display #show figure.where(kind: "theorem"): it => { |
