summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-08-26 19:17:58 +0200
committerGitHub <noreply@github.com>2024-08-26 17:17:58 +0000
commit4365e18454af4f8f53fe1198182cb5dc8f3d628e (patch)
treefe37649cec71b916d5119a033028e3f620247209 /tests
parentcb98eec60924a41889988644e5122d2e13eccbf1 (diff)
Improve realization and page layout (#4840)
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/counter-page-between-pages.pngbin0 -> 299 bytes
-rw-r--r--tests/ref/counter-page-footer-before-set-page.pngbin0 -> 535 bytes
-rw-r--r--tests/ref/counter-page-footer-only-update.pngbin0 -> 205 bytes
-rw-r--r--tests/ref/counter-page-header-before-set-page.pngbin0 -> 551 bytes
-rw-r--r--tests/ref/counter-page-header-only-update.pngbin0 -> 131 bytes
-rw-r--r--tests/ref/issue-1833-locate-place.pngbin0 -> 136 bytes
-rw-r--r--tests/ref/issue-1886-locate-after-metadata.pngbin0 -> 830 bytes
-rw-r--r--tests/ref/issue-2326-context-set-page.pngbin0 -> 676 bytes
-rw-r--r--tests/ref/issue-2841-pagebreak-to-weak.pngbin0 -> 391 bytes
-rw-r--r--tests/ref/issue-4029-locate-after-pagebreak.pngbin0 -> 698 bytes
-rw-r--r--tests/ref/issue-4029-locate-after-par-and-pagebreak.pngbin0 -> 785 bytes
-rw-r--r--tests/ref/issue-4029-locate-after-spacing.pngbin0 -> 706 bytes
-rw-r--r--tests/ref/issue-4363-set-page-after-tag.pngbin0 -> 278 bytes
-rw-r--r--tests/ref/list-item-styling.pngbin0 -> 1459 bytes
-rw-r--r--tests/ref/list-items-context.pngbin0 -> 382 bytes
-rw-r--r--tests/ref/locate-between-pages.pngbin0 -> 231 bytes
-rw-r--r--tests/ref/page-marginal-style-context.pngbin0 -> 348 bytes
-rw-r--r--tests/ref/page-marginal-style-empty.pngbin0 -> 152 bytes
-rw-r--r--tests/ref/page-marginal-style-page-call.pngbin0 -> 300 bytes
-rw-r--r--tests/ref/page-marginal-style-shared-initial-interaction.pngbin0 -> 504 bytes
-rw-r--r--tests/ref/page-marginal-style-show-rule-with-page-call.pngbin0 -> 1514 bytes
-rw-r--r--tests/ref/page-marginal-style-show-rule-with-pagebreak.pngbin0 -> 716 bytes
-rw-r--r--tests/ref/page-marginal-style-show-rule-with-set-page.pngbin0 -> 727 bytes
-rw-r--r--tests/ref/page-marginal-style-show-rule.pngbin0 -> 716 bytes
-rw-r--r--tests/ref/page-marginal-style-text-call-around-page-call.pngbin0 -> 529 bytes
-rw-r--r--tests/ref/page-marginal-style-text-call-around-pagebreak.pngbin0 -> 510 bytes
-rw-r--r--tests/ref/page-marginal-style-text-call-around-set-page.pngbin0 -> 531 bytes
-rw-r--r--tests/ref/page-marginal-style-text-call-code.pngbin0 -> 473 bytes
-rw-r--r--tests/ref/page-marginal-style-text-call.pngbin0 -> 473 bytes
-rw-r--r--tests/ref/page-marginal-style-text-set-first.pngbin0 -> 457 bytes
-rw-r--r--tests/ref/page-marginal-style-text-set.pngbin0 -> 457 bytes
-rw-r--r--tests/suite/introspection/counter.typ40
-rw-r--r--tests/suite/introspection/locate.typ90
-rw-r--r--tests/suite/layout/page.typ111
-rw-r--r--tests/suite/layout/pagebreak.typ9
-rw-r--r--tests/suite/model/list.typ10
36 files changed, 260 insertions, 0 deletions
diff --git a/tests/ref/counter-page-between-pages.png b/tests/ref/counter-page-between-pages.png
new file mode 100644
index 00000000..f79c586d
--- /dev/null
+++ b/tests/ref/counter-page-between-pages.png
Binary files differ
diff --git a/tests/ref/counter-page-footer-before-set-page.png b/tests/ref/counter-page-footer-before-set-page.png
new file mode 100644
index 00000000..2c6cd4ad
--- /dev/null
+++ b/tests/ref/counter-page-footer-before-set-page.png
Binary files differ
diff --git a/tests/ref/counter-page-footer-only-update.png b/tests/ref/counter-page-footer-only-update.png
new file mode 100644
index 00000000..e179face
--- /dev/null
+++ b/tests/ref/counter-page-footer-only-update.png
Binary files differ
diff --git a/tests/ref/counter-page-header-before-set-page.png b/tests/ref/counter-page-header-before-set-page.png
new file mode 100644
index 00000000..960776cf
--- /dev/null
+++ b/tests/ref/counter-page-header-before-set-page.png
Binary files differ
diff --git a/tests/ref/counter-page-header-only-update.png b/tests/ref/counter-page-header-only-update.png
new file mode 100644
index 00000000..07bb19d9
--- /dev/null
+++ b/tests/ref/counter-page-header-only-update.png
Binary files differ
diff --git a/tests/ref/issue-1833-locate-place.png b/tests/ref/issue-1833-locate-place.png
new file mode 100644
index 00000000..82b74e6d
--- /dev/null
+++ b/tests/ref/issue-1833-locate-place.png
Binary files differ
diff --git a/tests/ref/issue-1886-locate-after-metadata.png b/tests/ref/issue-1886-locate-after-metadata.png
new file mode 100644
index 00000000..3fb4708d
--- /dev/null
+++ b/tests/ref/issue-1886-locate-after-metadata.png
Binary files differ
diff --git a/tests/ref/issue-2326-context-set-page.png b/tests/ref/issue-2326-context-set-page.png
new file mode 100644
index 00000000..f0307d44
--- /dev/null
+++ b/tests/ref/issue-2326-context-set-page.png
Binary files differ
diff --git a/tests/ref/issue-2841-pagebreak-to-weak.png b/tests/ref/issue-2841-pagebreak-to-weak.png
new file mode 100644
index 00000000..b6404766
--- /dev/null
+++ b/tests/ref/issue-2841-pagebreak-to-weak.png
Binary files differ
diff --git a/tests/ref/issue-4029-locate-after-pagebreak.png b/tests/ref/issue-4029-locate-after-pagebreak.png
new file mode 100644
index 00000000..3b21c5d3
--- /dev/null
+++ b/tests/ref/issue-4029-locate-after-pagebreak.png
Binary files differ
diff --git a/tests/ref/issue-4029-locate-after-par-and-pagebreak.png b/tests/ref/issue-4029-locate-after-par-and-pagebreak.png
new file mode 100644
index 00000000..9d34677d
--- /dev/null
+++ b/tests/ref/issue-4029-locate-after-par-and-pagebreak.png
Binary files differ
diff --git a/tests/ref/issue-4029-locate-after-spacing.png b/tests/ref/issue-4029-locate-after-spacing.png
new file mode 100644
index 00000000..d2e61435
--- /dev/null
+++ b/tests/ref/issue-4029-locate-after-spacing.png
Binary files differ
diff --git a/tests/ref/issue-4363-set-page-after-tag.png b/tests/ref/issue-4363-set-page-after-tag.png
new file mode 100644
index 00000000..4002b2dd
--- /dev/null
+++ b/tests/ref/issue-4363-set-page-after-tag.png
Binary files differ
diff --git a/tests/ref/list-item-styling.png b/tests/ref/list-item-styling.png
new file mode 100644
index 00000000..72af2e1d
--- /dev/null
+++ b/tests/ref/list-item-styling.png
Binary files differ
diff --git a/tests/ref/list-items-context.png b/tests/ref/list-items-context.png
new file mode 100644
index 00000000..a19cbec4
--- /dev/null
+++ b/tests/ref/list-items-context.png
Binary files differ
diff --git a/tests/ref/locate-between-pages.png b/tests/ref/locate-between-pages.png
new file mode 100644
index 00000000..aac6de86
--- /dev/null
+++ b/tests/ref/locate-between-pages.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-context.png b/tests/ref/page-marginal-style-context.png
new file mode 100644
index 00000000..02c80bb1
--- /dev/null
+++ b/tests/ref/page-marginal-style-context.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-empty.png b/tests/ref/page-marginal-style-empty.png
new file mode 100644
index 00000000..10183129
--- /dev/null
+++ b/tests/ref/page-marginal-style-empty.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-page-call.png b/tests/ref/page-marginal-style-page-call.png
new file mode 100644
index 00000000..0d53a59f
--- /dev/null
+++ b/tests/ref/page-marginal-style-page-call.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-shared-initial-interaction.png b/tests/ref/page-marginal-style-shared-initial-interaction.png
new file mode 100644
index 00000000..76a76588
--- /dev/null
+++ b/tests/ref/page-marginal-style-shared-initial-interaction.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-show-rule-with-page-call.png b/tests/ref/page-marginal-style-show-rule-with-page-call.png
new file mode 100644
index 00000000..17a17140
--- /dev/null
+++ b/tests/ref/page-marginal-style-show-rule-with-page-call.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-show-rule-with-pagebreak.png b/tests/ref/page-marginal-style-show-rule-with-pagebreak.png
new file mode 100644
index 00000000..f05c64a7
--- /dev/null
+++ b/tests/ref/page-marginal-style-show-rule-with-pagebreak.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-show-rule-with-set-page.png b/tests/ref/page-marginal-style-show-rule-with-set-page.png
new file mode 100644
index 00000000..138f2272
--- /dev/null
+++ b/tests/ref/page-marginal-style-show-rule-with-set-page.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-show-rule.png b/tests/ref/page-marginal-style-show-rule.png
new file mode 100644
index 00000000..f05c64a7
--- /dev/null
+++ b/tests/ref/page-marginal-style-show-rule.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-call-around-page-call.png b/tests/ref/page-marginal-style-text-call-around-page-call.png
new file mode 100644
index 00000000..d5a2fd64
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-call-around-page-call.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-call-around-pagebreak.png b/tests/ref/page-marginal-style-text-call-around-pagebreak.png
new file mode 100644
index 00000000..c154a6bd
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-call-around-pagebreak.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-call-around-set-page.png b/tests/ref/page-marginal-style-text-call-around-set-page.png
new file mode 100644
index 00000000..f4174cd2
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-call-around-set-page.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-call-code.png b/tests/ref/page-marginal-style-text-call-code.png
new file mode 100644
index 00000000..1c8f155f
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-call-code.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-call.png b/tests/ref/page-marginal-style-text-call.png
new file mode 100644
index 00000000..1c8f155f
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-call.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-set-first.png b/tests/ref/page-marginal-style-text-set-first.png
new file mode 100644
index 00000000..6ede81de
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-set-first.png
Binary files differ
diff --git a/tests/ref/page-marginal-style-text-set.png b/tests/ref/page-marginal-style-text-set.png
new file mode 100644
index 00000000..6ede81de
--- /dev/null
+++ b/tests/ref/page-marginal-style-text-set.png
Binary files differ
diff --git a/tests/suite/introspection/counter.typ b/tests/suite/introspection/counter.typ
index 0d2be6e2..8cae32a4 100644
--- a/tests/suite/introspection/counter.typ
+++ b/tests/suite/introspection/counter.typ
@@ -62,6 +62,46 @@ At Beta, it was #context {
#counter(page).update(1)
#lorem(20)
+--- counter-page-footer-before-set-page ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+A
+#pagebreak()
+#counter(page).update(5)
+#set page(fill: aqua)
+B
+
+--- counter-page-header-before-set-page ---
+#set page(numbering: "1", number-align: top + center, margin: (top: 20pt))
+A
+#counter(page).update(4)
+#set page(fill: aqua)
+B
+
+--- counter-page-between-pages ---
+// The update happens conceptually between the pages.
+#set page(numbering: "1", margin: (bottom: 20pt))
+A
+#pagebreak()
+#counter(page).update(5)
+#set page(number-align: top + center, margin: (top: 20pt, bottom: 10pt))
+B
+
+--- counter-page-header-only-update ---
+// Header should not be affected by default.
+// To affect it, put the counter update before the `set page`.
+#set page(
+ numbering: "1",
+ number-align: top + center,
+ margin: (top: 20pt),
+)
+
+#counter(page).update(5)
+
+--- counter-page-footer-only-update ---
+// Footer should be affected by default.
+#set page(numbering: "1 / 1", margin: (bottom: 20pt))
+#counter(page).update(5)
+
--- counter-figure ---
// Count figures.
#figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_]
diff --git a/tests/suite/introspection/locate.typ b/tests/suite/introspection/locate.typ
index b3a77fde..18611dde 100644
--- a/tests/suite/introspection/locate.typ
+++ b/tests/suite/introspection/locate.typ
@@ -37,3 +37,93 @@
// Error: 10-25 selector matches multiple elements
#context locate(heading)
+
+--- locate-between-pages ---
+// Test locating tags that are before or between pages.
+#set page(height: 30pt)
+#context [
+ // Before the first page.
+ // (= at the very start of the first page, before the header)
+ #test(locate(<a>).position(), (page: 1, x: 0pt, y: 0pt))
+
+ // On the first page.
+ #test(locate(<b>).position(), (page: 1, x: 10pt, y: 10pt))
+
+ // Between the two pages.
+ // (= at the very start of the first page, before the header)
+ #test(locate(<c>).position(), (page: 2, x: 0pt, y: 0pt))
+
+ // After the last page.
+ // (= at the very end of the last page, after the footer)
+ #test(locate(<d>).position(), (page: 2, x: 0pt, y: 30pt))
+ #test(locate(<e>).position(), (page: 2, x: 0pt, y: 30pt))
+]
+
+#metadata(none) <a>
+#pagebreak(weak: true)
+#metadata(none) <b>
+A
+#pagebreak()
+#metadata(none) <c>
+#pagebreak(weak: true)
+B
+#pagebreak(weak: true)
+#metadata(none) <d>
+#pagebreak(weak: true)
+#metadata(none) <e>
+
+--- issue-4029-locate-after-spacing ---
+#set page(margin: 10pt)
+#show heading: it => v(40pt) + it
+
+= Introduction
+#context test(
+ locate(heading).position(),
+ (page: 1, x: 10pt, y: 50pt),
+)
+
+
+--- issue-4029-locate-after-pagebreak ---
+#set page(margin: 10pt)
+#show heading: it => pagebreak() + it
+
+= Introduction
+#context test(
+ locate(heading).position(),
+ (page: 2, x: 10pt, y: 10pt),
+)
+
+--- issue-4029-locate-after-par-and-pagebreak ---
+// Ensure that the heading's tag isn't stuck at the end of the paragraph.
+#set page(margin: 10pt)
+Par
+#show heading: it => pagebreak() + it
+= Introduction
+#context test(locate(heading).page(), 2)
+
+--- issue-1886-locate-after-metadata ---
+#show heading: it => {
+ metadata(it.label)
+ pagebreak(weak: true, to: "odd")
+ it
+}
+
+Hi
+= Hello <hello>
+= World <world>
+
+// The metadata's position does not migrate to the next page, but the heading's
+// does.
+#context {
+ test(locate(metadata.where(value: <hello>)).page(), 1)
+ test(locate(<hello>).page(), 3)
+ test(locate(metadata.where(value: <world>)).page(), 3)
+ test(locate(<world>).page(), 5)
+}
+
+--- issue-1833-locate-place ---
+#set page(height: 60pt)
+#context {
+ place(right + bottom, rect())
+ test(here().position(), (page: 1, x: 10pt, y: 10pt))
+}
diff --git a/tests/suite/layout/page.typ b/tests/suite/layout/page.typ
index 0e1f7729..a4abaec7 100644
--- a/tests/suite/layout/page.typ
+++ b/tests/suite/layout/page.typ
@@ -245,6 +245,98 @@ Look, ma, no page numbers!
#set page(header: auto, footer: auto)
Default page numbers now.
+--- page-marginal-style-text-set ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+#set text(red)
+Red
+
+--- page-marginal-style-text-set-first ---
+#set text(red)
+#set page(numbering: "1", margin: (bottom: 20pt))
+Red
+
+--- page-marginal-style-text-call ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+#text(red)[Red]
+
+--- page-marginal-style-text-call-code ---
+#{
+ set page(numbering: "1", margin: (bottom: 20pt))
+ text(red)[Red]
+}
+
+--- page-marginal-style-text-call-around-page-call ---
+#text(red, page(numbering: "1", margin: (bottom: 20pt))[Hello])
+
+--- page-marginal-style-text-call-around-set-page ---
+#text(red, {
+ set page(numbering: "1", margin: (bottom: 20pt))
+ text(style: "italic")[Hello]
+})
+
+--- page-marginal-style-text-call-around-pagebreak ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+A
+#text(red)[
+ #pagebreak(weak: true)
+ B
+]
+
+--- page-marginal-style-show-rule ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+= Introduction
+
+--- page-marginal-style-show-rule-with-set-page ---
+#show heading: it => {
+ set page(numbering: "1", margin: (bottom: 20pt))
+ it
+}
+
+= Introduction
+
+--- page-marginal-style-show-rule-with-page-call ---
+#show heading: page.with(fill: aqua)
+
+A
+= Introduction
+B
+
+--- page-marginal-style-show-rule-with-pagebreak ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+#show heading: it => {
+ pagebreak(weak: true)
+ it
+}
+
+= Introduction
+
+--- page-marginal-style-context ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+#show: it => context {
+ set text(red)
+ it
+}
+Hi
+
+--- page-marginal-style-shared-initial-interaction ---
+#set page(numbering: "1", margin: (bottom: 20pt))
+A
+#{
+ set text(fill: red)
+ pagebreak()
+}
+#text(fill: blue)[B]
+
+--- page-marginal-style-empty ---
+#set text(red)
+#set page(numbering: "1", margin: (bottom: 20pt))
+
+--- page-marginal-style-page-call ---
+#page(numbering: "1", margin: (bottom: 20pt))[
+ #set text(red)
+ A
+]
+
--- issue-2631-page-header-ordering ---
#set text(6pt)
#show heading: set text(6pt, weight: "regular")
@@ -272,3 +364,22 @@ Hi
#set page(fill: gray)
text
#pagebreak()
+
+--- issue-2326-context-set-page ---
+#context [
+ #set page(fill: aqua)
+ On page #here().page()
+]
+
+--- issue-3671-get-from-page-call ---
+#set page(margin: 5pt)
+#context test(page.margin, 5pt)
+#page(margin: 10pt, context test(page.margin, 10pt))
+
+--- issue-4363-set-page-after-tag ---
+#set page(fill: aqua)
+1
+#pagebreak()
+#metadata(none)
+#set page(fill: red)
+2
diff --git a/tests/suite/layout/pagebreak.typ b/tests/suite/layout/pagebreak.typ
index a1734596..3ca48b69 100644
--- a/tests/suite/layout/pagebreak.typ
+++ b/tests/suite/layout/pagebreak.typ
@@ -141,3 +141,12 @@ Some text on page 2
#set page(fill: orange) // This sets the color of the page starting from page 4
Some text on page 4
+
+--- issue-2591-single-weak-pagebreak ---
+#pagebreak(weak: true)
+
+--- issue-2841-pagebreak-to-weak ---
+First
+#pagebreak(to: "odd")
+#pagebreak(weak: true)
+Odd
diff --git a/tests/suite/model/list.typ b/tests/suite/model/list.typ
index f9275517..46f4621f 100644
--- a/tests/suite/model/list.typ
+++ b/tests/suite/model/list.typ
@@ -142,6 +142,16 @@ Hello
#list(tight: false)[A][B]
World
+--- list-items-context ---
+#context [+ A]
+#context [+ B]
+#context [+ C]
+
+--- list-item-styling ---
+- Hello
+#text(red)[- World]
+#text(green)[- What up?]
+
--- issue-2530-list-item-panic ---
// List item (pre-emptive)
#list.item[Hello]