summaryrefslogtreecommitdiff
path: root/tests/suite
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/suite
parentcb98eec60924a41889988644e5122d2e13eccbf1 (diff)
Improve realization and page layout (#4840)
Diffstat (limited to 'tests/suite')
-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
5 files changed, 260 insertions, 0 deletions
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]