diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-28 00:26:24 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-28 00:26:24 +0200 |
| commit | 90be79dc864c776a4d6f6739af671d4ea8407549 (patch) | |
| tree | 27de49da69a388d244c3786bd326d79694cd8e83 /tests/typ | |
| parent | 1a7ce3da02a25900dcdc09c110fe00229fd193d4 (diff) | |
Page background and foreground
Diffstat (limited to 'tests/typ')
| -rw-r--r-- | tests/typ/layout/locate-group.typ | 35 | ||||
| -rw-r--r-- | tests/typ/layout/page-marginals.typ | 3 |
2 files changed, 34 insertions, 4 deletions
diff --git a/tests/typ/layout/locate-group.typ b/tests/typ/layout/locate-group.typ index 5c022f5a..c3a5ddab 100644 --- a/tests/typ/layout/locate-group.typ +++ b/tests/typ/layout/locate-group.typ @@ -32,10 +32,9 @@ ..{ let seen = () for item in all { - if item.value not in seen { - seen.push(item.value) - (num(all, item.value), item.value) - } + if item.value in seen { continue } + (num(all, item.value), item.value) + seen.push(item.value) } } ))} @@ -43,6 +42,34 @@ As shown in #cite("abc") and #cite("def") and #cite("abc") ... --- +// Test lovely sidebar. +#let lovely = group("lovely") +#let words = ("Juliet", "soft", "fair", "maid") +#let regex = regex(words.map(p => "(" + p + ")").join("|")) +#show word: regex as underline(word) + lovely.entry(_ => {}) +#set page( + paper: "a8", + margins: (left: 25pt, rest: 15pt), + foreground: lovely.all(entries => { + let seen = () + for y in entries.map(it => it.y) { + if y in seen { continue } + let line = entries.filter(it => it.y == y) + for i, it in line { + let x = 10pt - 4pt * (line.len() - i - 1) + place(dx: x, dy: it.y - 8pt, [💗]) + } + seen.push(y) + } + }), +) + +But, soft! what light through yonder window breaks? It is the east, and Juliet +is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and +pale with grief, That thou her maid art far more fair than she: Be not her maid, +since she is envious. + +--- // Test that `all` contains `me`. // Ref: false #show it: heading as group("headings").entry( diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ index 6e8e3d85..9b323692 100644 --- a/tests/typ/layout/page-marginals.typ +++ b/tests/typ/layout/page-marginals.typ @@ -7,6 +7,9 @@ text(0.8em)[_Chapter 1_] }), footer: page => v(5pt) + align(center)[\~ #page \~], + background: n => if n <= 2 { + place(center + horizon, circle(radius: 1cm, fill: luma(90%))) + } ) But, soft! what light through yonder window breaks? It is the east, and Juliet |
