summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-28 17:57:16 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-28 17:57:16 +0100
commit836692e73cff0356e409a9ba5b4887b86809d4ca (patch)
treee174178047c368c66746ee073eea1b3129825479 /tests
parent989d170dc7318ca3cbaa5b76760eb14f4e6a8605 (diff)
Widow and orphan prevention
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/layout/grid-3.pngbin64866 -> 44418 bytes
-rw-r--r--tests/ref/layout/orphan-heading.pngbin0 -> 8239 bytes
-rw-r--r--tests/ref/layout/orphan-widow.pngbin0 -> 71274 bytes
-rw-r--r--tests/typ/graphics/image.typ2
-rw-r--r--tests/typ/graphics/shape-aspect.typ2
-rw-r--r--tests/typ/layout/columns.typ4
-rw-r--r--tests/typ/layout/grid-3.typ18
-rw-r--r--tests/typ/layout/orphan-heading.typ8
-rw-r--r--tests/typ/layout/orphan-widow.typ23
9 files changed, 35 insertions, 22 deletions
diff --git a/tests/ref/layout/grid-3.png b/tests/ref/layout/grid-3.png
index c17a5873..1bb76292 100644
--- a/tests/ref/layout/grid-3.png
+++ b/tests/ref/layout/grid-3.png
Binary files differ
diff --git a/tests/ref/layout/orphan-heading.png b/tests/ref/layout/orphan-heading.png
new file mode 100644
index 00000000..aa5a7838
--- /dev/null
+++ b/tests/ref/layout/orphan-heading.png
Binary files differ
diff --git a/tests/ref/layout/orphan-widow.png b/tests/ref/layout/orphan-widow.png
new file mode 100644
index 00000000..8fc523a6
--- /dev/null
+++ b/tests/ref/layout/orphan-widow.png
Binary files differ
diff --git a/tests/typ/graphics/image.typ b/tests/typ/graphics/image.typ
index 3c906d4f..e97365cd 100644
--- a/tests/typ/graphics/image.typ
+++ b/tests/typ/graphics/image.typ
@@ -38,7 +38,7 @@
---
// Does not fit to remaining height of page.
#set page(height: 60pt)
-Stuff \
+Stuff #parbreak()
Stuff
#image("/res/rhino.png")
diff --git a/tests/typ/graphics/shape-aspect.typ b/tests/typ/graphics/shape-aspect.typ
index 464d1827..f2dd9b51 100644
--- a/tests/typ/graphics/shape-aspect.typ
+++ b/tests/typ/graphics/shape-aspect.typ
@@ -36,7 +36,7 @@
---
// Test square that is overflowing due to its aspect ratio.
#set page(width: 40pt, height: 20pt, margin: 5pt)
-#square(width: 100%)
+#square(width: 100%) #parbreak()
#square(width: 100%)[Hello]
---
diff --git a/tests/typ/layout/columns.typ b/tests/typ/layout/columns.typ
index 1e77e6bc..315393a0 100644
--- a/tests/typ/layout/columns.typ
+++ b/tests/typ/layout/columns.typ
@@ -52,8 +52,8 @@ a page for a test but it does get the job done.
#set page(height: 3.25cm, width: 7.05cm, columns: 3)
#set columns(gutter: 30pt)
-#rect(width: 100%, height: 2.5cm, fill: conifer)
-#rect(width: 100%, height: 2cm, fill: eastern)
+#rect(width: 100%, height: 2.5cm, fill: conifer) #parbreak()
+#rect(width: 100%, height: 2cm, fill: eastern) #parbreak()
#circle(fill: eastern)
---
diff --git a/tests/typ/layout/grid-3.typ b/tests/typ/layout/grid-3.typ
index 6b7dc47f..c55f22a6 100644
--- a/tests/typ/layout/grid-3.typ
+++ b/tests/typ/layout/grid-3.typ
@@ -59,21 +59,3 @@
[rofl],
[E\ ]*4,
)
-
----
-// Test partition of `fr` units before and after multi-region layout.
-#set page(width: 5cm, height: 4cm)
-#grid(
- columns: 2 * (1fr,),
- rows: (1fr, 2fr, auto, 1fr, 1cm),
- row-gutter: 10pt,
- rect(fill: rgb("ff0000"))[No height],
- [foo],
- rect(fill: rgb("fc0030"))[Still no height],
- [bar],
- [The nature of being itself is in question. Am I One? What is being alive?],
- [baz],
- [The answer],
- [42],
- [Other text of interest],
-)
diff --git a/tests/typ/layout/orphan-heading.typ b/tests/typ/layout/orphan-heading.typ
new file mode 100644
index 00000000..ef3de885
--- /dev/null
+++ b/tests/typ/layout/orphan-heading.typ
@@ -0,0 +1,8 @@
+// Test that a heading doesn't become an orphan.
+
+---
+#set page(height: 100pt)
+#lorem(12)
+
+= Introduction
+This is the start and it goes on.
diff --git a/tests/typ/layout/orphan-widow.typ b/tests/typ/layout/orphan-widow.typ
new file mode 100644
index 00000000..445b44e3
--- /dev/null
+++ b/tests/typ/layout/orphan-widow.typ
@@ -0,0 +1,23 @@
+// Test widow and orphan prevention.
+
+---
+#set page("a8", height: 150pt)
+#set text(weight: 700)
+
+// Fits fully onto the first page.
+#set text(blue)
+#lorem(27)
+
+// The first line would fit, but is moved to the second page.
+#lorem(20)
+
+// The second-to-last line is moved to the third page so that the last is isn't
+// as lonely.
+#set text(maroon)
+#lorem(11)
+
+#lorem(13)
+
+// All three lines go to the next page.
+#set text(olive)
+#lorem(10)