diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-01-30 15:24:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-30 14:24:41 +0000 |
| commit | b744b8781835d704236210d8a3dd603c6a29c8d0 (patch) | |
| tree | 3c0d6b5118dcececafce14df2fddf9932dce2923 /tests/typ/compiler | |
| parent | a1e8560ca65cefaa423959ef3f2881b23528de8d (diff) | |
Respect set rules in where selectors (#3290)
Diffstat (limited to 'tests/typ/compiler')
| -rw-r--r-- | tests/typ/compiler/select-where-styles.typ | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/typ/compiler/select-where-styles.typ b/tests/typ/compiler/select-where-styles.typ new file mode 100644 index 00000000..028be2e9 --- /dev/null +++ b/tests/typ/compiler/select-where-styles.typ @@ -0,0 +1,91 @@ +// Test that where selectors also work with settable fields. + +--- +// Test that where selectors also trigger on set rule fields. +#show raw.where(block: false): box.with( + fill: luma(220), + inset: (x: 3pt, y: 0pt), + outset: (y: 3pt), + radius: 2pt, +) + +This is #raw("fn main() {}") some text. + +--- +// Note: This show rule is horribly inefficient because it triggers for +// every individual text element. But it should still work. +#show text.where(lang: "de"): set text(red) + +#set text(lang: "es") +Hola, mundo! + +#set text(lang: "de") +Hallo Welt! + +#set text(lang: "en") +Hello World! + +--- +// Test that folding is taken into account. +#set text(5pt) +#set text(2em) + +#[ + #show text.where(size: 2em): set text(blue) + 2em not blue +] + +#[ + #show text.where(size: 10pt): set text(blue) + 10pt blue +] + +--- +// Test again that folding is taken into account. +#set rect(width: 40pt, height: 10pt) +#set rect(stroke: blue) +#set rect(stroke: 2pt) + +#{ + show rect.where(stroke: blue): "Not Triggered" + rect() +} +#{ + show rect.where(stroke: 2pt): "Not Triggered" + rect() +} +#{ + show rect.where(stroke: 2pt + blue): "Triggered" + rect() +} + +--- +// Test that resolving is *not* taken into account. +#set line(start: (1em, 1em + 2pt)) + +#{ + show line.where(start: (1em, 1em + 2pt)): "Triggered" + line() +} +#{ + show line.where(start: (10pt, 12pt)): "Not Triggered" + line() +} + + +--- +// Test again that resolving is *not* taken into account. +#set text(hyphenate: auto) + +#[ + #show text.where(hyphenate: auto): underline + Auto +] +#[ + #show text.where(hyphenate: true): underline + True +] +#[ + #show text.where(hyphenate: false): underline + False +] |
