summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/show-node.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-29 13:37:25 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-29 14:18:13 +0100
commit0efe669278a5e1c3f2985eba2f3360e91159c54a (patch)
tree502712857c48f0decb5e698257c0a96d358a436e /tests/typ/compiler/show-node.typ
parent836692e73cff0356e409a9ba5b4887b86809d4ca (diff)
Reorganize library and tests
Diffstat (limited to 'tests/typ/compiler/show-node.typ')
-rw-r--r--tests/typ/compiler/show-node.typ104
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/typ/compiler/show-node.typ b/tests/typ/compiler/show-node.typ
new file mode 100644
index 00000000..98f36f13
--- /dev/null
+++ b/tests/typ/compiler/show-node.typ
@@ -0,0 +1,104 @@
+// Test node show rules.
+
+---
+// Override lists.
+#show list: it => "(" + it.items.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)
+ 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 unknown field "page"
+#show heading: it => it.page
+= Heading
+
+---
+// Error: 7-12 this function is not selectable
+#show upper: it => {}
+
+---
+// Error: 7-11 to select text, please use a string or regex instead
+#show text: it => {}
+
+---
+// Error: 16-20 expected content or function, found integer
+#show heading: 1234
+= Heading
+
+---
+// Error: 7-10 expected selector, found color
+#show red: []
+
+---
+// Error: 7-25 show is only allowed directly in code and content blocks
+{ 1 + show heading: none }