mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
39 lines
515 B
XML
39 lines
515 B
XML
// Test code blocks.
|
|
|
|
---
|
|
All none
|
|
|
|
// Nothing evaluates to none.
|
|
{}
|
|
|
|
// Let evaluates to none.
|
|
{ let v = 0 }
|
|
|
|
// Trailing none evaluates to none.
|
|
{
|
|
type("")
|
|
none
|
|
}
|
|
|
|
---
|
|
// Evaluates to single expression.
|
|
{ "Hello" }
|
|
|
|
// Evaluates to trailing expression.
|
|
{ let x = "Hel"; x + "lo" }
|
|
|
|
// Evaluates to concatenation of for loop bodies.
|
|
{
|
|
let parts = ("Hel", "lo")
|
|
for s in parts [{s}]
|
|
}
|
|
|
|
---
|
|
// Works the same way in code environment.
|
|
// Ref: false
|
|
#test(3, {
|
|
let x = 1
|
|
let y = 2
|
|
x + y
|
|
})
|