mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
- Templates scope state changes - State-modifying function operate in place instead of returning a template - Internal template representation contains actual owned nodes instead of a pointer to a syntax tree + an expression map - No more wide calls
36 lines
661 B
Typst
36 lines
661 B
Typst
// Test the `pad` function.
|
|
|
|
---
|
|
// Use for indentation.
|
|
#pad(left: 10pt, [Indented!])
|
|
|
|
// All sides together.
|
|
#rect(fill: conifer,
|
|
pad(10pt, right: 20pt,
|
|
rect(width: 20pt, height: 20pt, fill: rgb("eb5278"))
|
|
)
|
|
)
|
|
|
|
Hi #box(pad(left: 10pt)[]) there
|
|
|
|
---
|
|
#let pad(body) = pad(left: 10pt, right: 10pt, body)
|
|
|
|
// Pad inherits expansion behaviour from stack ....
|
|
#pad[PL #align(right)[PR]]
|
|
|
|
// ... block ...
|
|
#block(pad[PL #align(right)[PR]])
|
|
|
|
// ... and box.
|
|
#box(pad[PL #align(right)[PR]])
|
|
|
|
---
|
|
// Test that the pad node doesn't consume the whole region.
|
|
|
|
#page(height: 6cm)
|
|
|
|
#align(left)[Before]
|
|
#pad(10pt, image("../../res/tiger.jpg"))
|
|
#align(right)[After]
|