summaryrefslogtreecommitdiff
path: root/tests/typ/style/show-node.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-03 16:43:44 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-03 16:43:44 +0200
commite18a896a93cae987aa30addd40e678bf0064fd31 (patch)
tree5371e7d502258fa99414d89969f3b97f438257e3 /tests/typ/style/show-node.typ
parentd59109e8fffa1d0b03234329e12f5d3e578804e8 (diff)
Test recursive show rules
Diffstat (limited to 'tests/typ/style/show-node.typ')
-rw-r--r--tests/typ/style/show-node.typ67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ
new file mode 100644
index 00000000..4fcee9aa
--- /dev/null
+++ b/tests/typ/style/show-node.typ
@@ -0,0 +1,67 @@
+// Test node show rules.
+
+---
+// Override lists.
+#set list(around: none)
+#show v: list as "(" + v.items.join(", ") + ")"
+
+- A
+ - B
+ - C
+- D
+- E
+
+---
+// Test full reset.
+#set heading(size: 1em, strong: false, around: none)
+#show heading as [B]
+A [= Heading] C
+
+---
+// Test full removal.
+#show heading as []
+#set heading(around: none)
+
+Where is
+= There are not headings around here!
+my heading?
+
+---
+// Test integrated example.
+#set heading(size: 1em)
+#show node: heading as {
+ move(dy: -1pt)[📖]
+ h(5pt)
+ if node.level == 1 {
+ underline(text(1.25em, blue, node.body))
+ } else {
+ text(red, node.body)
+ }
+}
+
+= Task 1
+Some text.
+
+== Subtask
+Some more text.
+
+= Task 2
+Another text.
+
+---
+// Error: 18-22 expected content, found string
+#show heading as "hi"
+= Heading
+
+---
+// Error: 25-29 unknown field "page"
+#show it: heading as it.page
+= Heading
+
+---
+// Error: 10-15 this function cannot be customized with show
+#show _: upper as {}
+
+---
+// Error: 2-16 set, show and wrap are only allowed directly in markup
+{show list as a}