summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-layout/src/inline/finalize.rs3
-rw-r--r--crates/typst-layout/src/inline/line.rs3
-rw-r--r--crates/typst-library/src/model/par.rs9
-rw-r--r--crates/typst-library/src/text/raw.rs2
-rw-r--r--tests/ref/issue-3191-raw-indent-shrink.pngbin1422 -> 0 bytes
-rw-r--r--tests/ref/issue-3191-raw-justify.pngbin0 -> 622 bytes
-rw-r--r--tests/suite/text/raw.typ25
7 files changed, 12 insertions, 30 deletions
diff --git a/crates/typst-layout/src/inline/finalize.rs b/crates/typst-layout/src/inline/finalize.rs
index 599ace9d..57044f0e 100644
--- a/crates/typst-layout/src/inline/finalize.rs
+++ b/crates/typst-layout/src/inline/finalize.rs
@@ -27,10 +27,9 @@ pub fn finalize(
};
// Stack the lines into one frame per region.
- let shrink = ParElem::shrink_in(styles);
lines
.iter()
- .map(|line| commit(engine, p, line, width, region.y, shrink, locator, styles))
+ .map(|line| commit(engine, p, line, width, region.y, locator, styles))
.collect::<SourceResult<_>>()
.map(Fragment::frames)
}
diff --git a/crates/typst-layout/src/inline/line.rs b/crates/typst-layout/src/inline/line.rs
index 596e109e..6dca95a9 100644
--- a/crates/typst-layout/src/inline/line.rs
+++ b/crates/typst-layout/src/inline/line.rs
@@ -417,7 +417,6 @@ pub fn commit(
line: &Line,
width: Abs,
full: Abs,
- shrink: bool,
locator: &mut SplitLocator<'_>,
styles: StyleChain,
) -> SourceResult<Frame> {
@@ -469,7 +468,7 @@ pub fn commit(
let shrinkability = line.shrinkability();
let stretchability = line.stretchability();
- if remaining < Abs::zero() && shrinkability > Abs::zero() && shrink {
+ if remaining < Abs::zero() && shrinkability > Abs::zero() {
// Attempt to reduce the length of the line, using shrinkability.
justification_ratio = (remaining / shrinkability).max(-1.0);
remaining = (remaining + shrinkability).min(Abs::zero());
diff --git a/crates/typst-library/src/model/par.rs b/crates/typst-library/src/model/par.rs
index a43499d8..8b82abdf 100644
--- a/crates/typst-library/src/model/par.rs
+++ b/crates/typst-library/src/model/par.rs
@@ -126,15 +126,6 @@ pub struct ParElem {
#[resolve]
pub hanging_indent: Length,
- /// Indicates whether an overflowing line should be shrunk.
- ///
- /// This property is set to `false` on raw blocks, because shrinking a line
- /// could visually break the indentation.
- #[ghost]
- #[internal]
- #[default(true)]
- pub shrink: bool,
-
/// The contents of the paragraph.
#[external]
#[required]
diff --git a/crates/typst-library/src/text/raw.rs b/crates/typst-library/src/text/raw.rs
index 8691afcb..f318f06e 100644
--- a/crates/typst-library/src/text/raw.rs
+++ b/crates/typst-library/src/text/raw.rs
@@ -473,7 +473,7 @@ impl ShowSet for Packed<RawElem> {
out.set(TextElem::set_size(TextSize(Em::new(0.8).into())));
out.set(TextElem::set_font(FontList(vec![FontFamily::new("DejaVu Sans Mono")])));
if self.block(styles) {
- out.set(ParElem::set_shrink(false));
+ out.set(ParElem::set_justify(false));
}
out
}
diff --git a/tests/ref/issue-3191-raw-indent-shrink.png b/tests/ref/issue-3191-raw-indent-shrink.png
deleted file mode 100644
index e7ac73b7..00000000
--- a/tests/ref/issue-3191-raw-indent-shrink.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/issue-3191-raw-justify.png b/tests/ref/issue-3191-raw-justify.png
new file mode 100644
index 00000000..1466ccf0
--- /dev/null
+++ b/tests/ref/issue-3191-raw-justify.png
Binary files differ
diff --git a/tests/suite/text/raw.typ b/tests/suite/text/raw.typ
index d6f6978e..fa9e630f 100644
--- a/tests/suite/text/raw.typ
+++ b/tests/suite/text/raw.typ
@@ -594,23 +594,16 @@ fn main() {
}
```
---- issue-3191-raw-indent-shrink ---
-// Spaces in raw blocks should not be shrunk as it would mess up the indentation
-// of code.
-#set par(justify: true)
-
-#show raw.where(block: true): block.with(
- fill: luma(240),
- inset: 10pt,
-)
+--- issue-3191-raw-justify ---
+// Raw blocks should not be justified by default.
+```
+a b c --------------------
+```
-#block(
- width: 60%,
- ```py
- for x in xs:
- print("x=",x)
- ```
-)
+#show raw: set par(justify: true)
+```
+a b c --------------------
+```
--- issue-3191-raw-normal-paragraphs-still-shrink ---
// In normal paragraphs, spaces should still be shrunk.