summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-02 19:45:53 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-02 19:47:42 +0200
commitb469f30c83f50a5728888c7a800d31321e160e5d (patch)
tree2a6b017de627d55de3925b9985906d1b151d793b
parentfa4878f7d00052d1c960b836c7d689e4e7b8428e (diff)
Fix block spacing
-rw-r--r--library/src/layout/mod.rs8
-rw-r--r--tests/ref/layout/block-spacing.pngbin0 -> 1868 bytes
-rw-r--r--tests/typ/layout/block-spacing.typ9
3 files changed, 15 insertions, 2 deletions
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index e93b2e02..d12ce158 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -466,8 +466,12 @@ impl<'a> FlowBuilder<'a> {
self.0.push(spacing.pack(), styles);
}
- let above = BlockElem::above_in(styles);
- let below = BlockElem::below_in(styles);
+ let (above, below) = if let Some(block) = content.to::<BlockElem>() {
+ (block.above(styles), block.below(styles))
+ } else {
+ (BlockElem::above_in(styles), BlockElem::below_in(styles))
+ };
+
self.0.push(above.pack(), styles);
self.0.push(content.clone(), styles);
self.0.push(below.pack(), styles);
diff --git a/tests/ref/layout/block-spacing.png b/tests/ref/layout/block-spacing.png
new file mode 100644
index 00000000..d73abac0
--- /dev/null
+++ b/tests/ref/layout/block-spacing.png
Binary files differ
diff --git a/tests/typ/layout/block-spacing.typ b/tests/typ/layout/block-spacing.typ
new file mode 100644
index 00000000..2c636676
--- /dev/null
+++ b/tests/typ/layout/block-spacing.typ
@@ -0,0 +1,9 @@
+// Test block spacing.
+
+---
+#set block(spacing: 10pt)
+Hello
+
+There
+
+#block(spacing: 20pt)[Further down]