summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/show-node.typ
blob: 42aee506906ed98748e9b8c0c44aecd4d8eea2cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Test show rules.

---
// Override lists.
#show list: it => "(" + it.children.map(v => v.body).join(", ") + ")"

- A
  - B
  - C
- D
- E

---
// Test full reset.
#show heading: [B]
#show heading: set text(size: 10pt, weight: 400)
A #[= Heading] C

---
// Test full removal.
#show heading: none

Where is
= There are no headings around here!
my heading?

---
// Test integrated example.
#show heading: it => block({
  set text(10pt)
  box(move(dy: -1pt)[📖])
  h(5pt)
  if it.level == 1 {
    underline(text(1.25em, blue, it.body))
  } else {
    text(red, it.body)
  }
})

= Task 1
Some text.

== Subtask
Some more text.

= Task 2
Another text.

---
// Test set and show in code blocks.
#show heading: it => {
  set text(red)
  show "ding": [🛎]
  it.body
}

= Heading

---
// Test that scoping works as expected.
#{
  let world = [ World ]
  show "W": strong
  world
  {
    set text(blue)
    show: it => {
      show "o": "Ø"
      it
    }
    world
  }
  world
}

---
#show heading: [1234]
= Heading

---
// Error: 25-29 content does not contain field "page"
#show heading: it => it.page
= Heading

---
#show text: none
Hey

---
// Error: 7-12 only element functions can be used as selectors
#show upper: it => {}

---
// Error: 16-20 expected content or function, found integer
#show heading: 1234
= Heading

---
// Error: 7-10 expected function, label, string, regular expression, location, or selector, found color
#show red: []

---
// Error: 7-25 show is only allowed directly in code and content blocks
#(1 + show heading: none)