mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
67 lines
943 B
Typst
67 lines
943 B
Typst
// Test recursive show rules.
|
|
|
|
---
|
|
// Test basic identity.
|
|
#show heading: it => it
|
|
= Heading
|
|
|
|
---
|
|
// Test more recipes down the chain.
|
|
#show list: scale.with(origin: left, x: 80%)
|
|
#show heading: []
|
|
#show enum: []
|
|
- Actual
|
|
- Tight
|
|
- List
|
|
= Nope
|
|
|
|
---
|
|
// Test recursive base recipe. (Burn it with fire!)
|
|
#set list(label: [- Hey])
|
|
- Labelless
|
|
- List
|
|
|
|
---
|
|
// Test show rule in function.
|
|
#let starwars(body) = [
|
|
#show list: it => {
|
|
stack(dir: ltr,
|
|
text(red, it),
|
|
1fr,
|
|
scale(x: -100%, text(blue, it)),
|
|
)
|
|
}
|
|
#body
|
|
]
|
|
|
|
- Normal list
|
|
#starwars[
|
|
- Star
|
|
- Wars
|
|
- List
|
|
]
|
|
- Normal list
|
|
|
|
---
|
|
// Test multi-recursion with nested lists.
|
|
#set rect(inset: 2pt)
|
|
#show list: rect.with(stroke: blue)
|
|
#show list: rect.with(stroke: red)
|
|
|
|
- List
|
|
- Nested
|
|
- List
|
|
- Recursive!
|
|
|
|
---
|
|
// Inner heading is not finalized. Bug?
|
|
#set heading(around: none)
|
|
#show heading: it => it.body
|
|
#show heading: [
|
|
= A [
|
|
= B
|
|
]
|
|
]
|
|
|
|
= Discarded
|