From 4365e18454af4f8f53fe1198182cb5dc8f3d628e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 26 Aug 2024 19:17:58 +0200 Subject: Improve realization and page layout (#4840) --- tests/ref/counter-page-between-pages.png | Bin 0 -> 299 bytes tests/ref/counter-page-footer-before-set-page.png | Bin 0 -> 535 bytes tests/ref/counter-page-footer-only-update.png | Bin 0 -> 205 bytes tests/ref/counter-page-header-before-set-page.png | Bin 0 -> 551 bytes tests/ref/counter-page-header-only-update.png | Bin 0 -> 131 bytes tests/ref/issue-1833-locate-place.png | Bin 0 -> 136 bytes tests/ref/issue-1886-locate-after-metadata.png | Bin 0 -> 830 bytes tests/ref/issue-2326-context-set-page.png | Bin 0 -> 676 bytes tests/ref/issue-2841-pagebreak-to-weak.png | Bin 0 -> 391 bytes tests/ref/issue-4029-locate-after-pagebreak.png | Bin 0 -> 698 bytes .../issue-4029-locate-after-par-and-pagebreak.png | Bin 0 -> 785 bytes tests/ref/issue-4029-locate-after-spacing.png | Bin 0 -> 706 bytes tests/ref/issue-4363-set-page-after-tag.png | Bin 0 -> 278 bytes tests/ref/list-item-styling.png | Bin 0 -> 1459 bytes tests/ref/list-items-context.png | Bin 0 -> 382 bytes tests/ref/locate-between-pages.png | Bin 0 -> 231 bytes tests/ref/page-marginal-style-context.png | Bin 0 -> 348 bytes tests/ref/page-marginal-style-empty.png | Bin 0 -> 152 bytes tests/ref/page-marginal-style-page-call.png | Bin 0 -> 300 bytes ...e-marginal-style-shared-initial-interaction.png | Bin 0 -> 504 bytes ...age-marginal-style-show-rule-with-page-call.png | Bin 0 -> 1514 bytes ...age-marginal-style-show-rule-with-pagebreak.png | Bin 0 -> 716 bytes ...page-marginal-style-show-rule-with-set-page.png | Bin 0 -> 727 bytes tests/ref/page-marginal-style-show-rule.png | Bin 0 -> 716 bytes ...e-marginal-style-text-call-around-page-call.png | Bin 0 -> 529 bytes ...e-marginal-style-text-call-around-pagebreak.png | Bin 0 -> 510 bytes ...ge-marginal-style-text-call-around-set-page.png | Bin 0 -> 531 bytes tests/ref/page-marginal-style-text-call-code.png | Bin 0 -> 473 bytes tests/ref/page-marginal-style-text-call.png | Bin 0 -> 473 bytes tests/ref/page-marginal-style-text-set-first.png | Bin 0 -> 457 bytes tests/ref/page-marginal-style-text-set.png | Bin 0 -> 457 bytes tests/suite/introspection/counter.typ | 40 ++++++++ tests/suite/introspection/locate.typ | 90 +++++++++++++++++ tests/suite/layout/page.typ | 111 +++++++++++++++++++++ tests/suite/layout/pagebreak.typ | 9 ++ tests/suite/model/list.typ | 10 ++ 36 files changed, 260 insertions(+) create mode 100644 tests/ref/counter-page-between-pages.png create mode 100644 tests/ref/counter-page-footer-before-set-page.png create mode 100644 tests/ref/counter-page-footer-only-update.png create mode 100644 tests/ref/counter-page-header-before-set-page.png create mode 100644 tests/ref/counter-page-header-only-update.png create mode 100644 tests/ref/issue-1833-locate-place.png create mode 100644 tests/ref/issue-1886-locate-after-metadata.png create mode 100644 tests/ref/issue-2326-context-set-page.png create mode 100644 tests/ref/issue-2841-pagebreak-to-weak.png create mode 100644 tests/ref/issue-4029-locate-after-pagebreak.png create mode 100644 tests/ref/issue-4029-locate-after-par-and-pagebreak.png create mode 100644 tests/ref/issue-4029-locate-after-spacing.png create mode 100644 tests/ref/issue-4363-set-page-after-tag.png create mode 100644 tests/ref/list-item-styling.png create mode 100644 tests/ref/list-items-context.png create mode 100644 tests/ref/locate-between-pages.png create mode 100644 tests/ref/page-marginal-style-context.png create mode 100644 tests/ref/page-marginal-style-empty.png create mode 100644 tests/ref/page-marginal-style-page-call.png create mode 100644 tests/ref/page-marginal-style-shared-initial-interaction.png create mode 100644 tests/ref/page-marginal-style-show-rule-with-page-call.png create mode 100644 tests/ref/page-marginal-style-show-rule-with-pagebreak.png create mode 100644 tests/ref/page-marginal-style-show-rule-with-set-page.png create mode 100644 tests/ref/page-marginal-style-show-rule.png create mode 100644 tests/ref/page-marginal-style-text-call-around-page-call.png create mode 100644 tests/ref/page-marginal-style-text-call-around-pagebreak.png create mode 100644 tests/ref/page-marginal-style-text-call-around-set-page.png create mode 100644 tests/ref/page-marginal-style-text-call-code.png create mode 100644 tests/ref/page-marginal-style-text-call.png create mode 100644 tests/ref/page-marginal-style-text-set-first.png create mode 100644 tests/ref/page-marginal-style-text-set.png (limited to 'tests') 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 Binary files /dev/null and b/tests/ref/counter-page-between-pages.png 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 Binary files /dev/null and b/tests/ref/counter-page-footer-before-set-page.png 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 Binary files /dev/null and b/tests/ref/counter-page-footer-only-update.png 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 Binary files /dev/null and b/tests/ref/counter-page-header-before-set-page.png 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 Binary files /dev/null and b/tests/ref/counter-page-header-only-update.png 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 Binary files /dev/null and b/tests/ref/issue-1833-locate-place.png 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 Binary files /dev/null and b/tests/ref/issue-1886-locate-after-metadata.png 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 Binary files /dev/null and b/tests/ref/issue-2326-context-set-page.png 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 Binary files /dev/null and b/tests/ref/issue-2841-pagebreak-to-weak.png 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 Binary files /dev/null and b/tests/ref/issue-4029-locate-after-pagebreak.png 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 Binary files /dev/null and b/tests/ref/issue-4029-locate-after-par-and-pagebreak.png 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 Binary files /dev/null and b/tests/ref/issue-4029-locate-after-spacing.png 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 Binary files /dev/null and b/tests/ref/issue-4363-set-page-after-tag.png differ diff --git a/tests/ref/list-item-styling.png b/tests/ref/list-item-styling.png new file mode 100644 index 00000000..72af2e1d Binary files /dev/null and b/tests/ref/list-item-styling.png differ diff --git a/tests/ref/list-items-context.png b/tests/ref/list-items-context.png new file mode 100644 index 00000000..a19cbec4 Binary files /dev/null and b/tests/ref/list-items-context.png differ diff --git a/tests/ref/locate-between-pages.png b/tests/ref/locate-between-pages.png new file mode 100644 index 00000000..aac6de86 Binary files /dev/null and b/tests/ref/locate-between-pages.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-context.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-empty.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-page-call.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-shared-initial-interaction.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-show-rule-with-page-call.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-show-rule-with-pagebreak.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-show-rule-with-set-page.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-show-rule.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-call-around-page-call.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-call-around-pagebreak.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-call-around-set-page.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-call-code.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-call.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-set-first.png 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 Binary files /dev/null and b/tests/ref/page-marginal-style-text-set.png 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().position(), (page: 1, x: 0pt, y: 0pt)) + + // On the first page. + #test(locate().position(), (page: 1, x: 10pt, y: 10pt)) + + // Between the two pages. + // (= at the very start of the first page, before the header) + #test(locate().position(), (page: 2, x: 0pt, y: 0pt)) + + // After the last page. + // (= at the very end of the last page, after the footer) + #test(locate().position(), (page: 2, x: 0pt, y: 30pt)) + #test(locate().position(), (page: 2, x: 0pt, y: 30pt)) +] + +#metadata(none) +#pagebreak(weak: true) +#metadata(none) +A +#pagebreak() +#metadata(none) +#pagebreak(weak: true) +B +#pagebreak(weak: true) +#metadata(none) +#pagebreak(weak: true) +#metadata(none) + +--- 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 += World + +// The metadata's position does not migrate to the next page, but the heading's +// does. +#context { + test(locate(metadata.where(value: )).page(), 1) + test(locate().page(), 3) + test(locate(metadata.where(value: )).page(), 3) + test(locate().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] -- cgit v1.2.3