mirror of
https://github.com/typst/typst
synced 2025-05-16 18:15:29 +08:00
This creates a smaller state machine helper type for softness coalescing, which does not own the resulting nodes. While this creates a bit more duplication in stack and par builder, it makes it a lot easier to integrate additional logic into the paragraph builder. Furthermore: - Line breaks are now "hard", that is, not coalesced with each other. - Text nodes with equal style are now merged allowing for example `f{}i` to form a ligature.
36 lines
696 B
Typst
36 lines
696 B
Typst
// Test spacing around control flow structures.
|
|
|
|
---
|
|
// Spacing around let.
|
|
|
|
// Error: 6 expected identifier
|
|
A#let;B \
|
|
A#let x = 1;B #test(x, 1) \
|
|
A #let x = 2;B #test(x, 2) \
|
|
A#let x = 3; B #test(x, 3)
|
|
|
|
---
|
|
// Spacing around if-else.
|
|
|
|
A#if true [B]C \
|
|
A#if true [B] C \
|
|
A #if true{"B"}C \
|
|
A #if true{"B"} C \
|
|
A#if false [] #else [B]C \
|
|
A#if true [B] #else [] C
|
|
|
|
---
|
|
// Spacing around while loop.
|
|
|
|
#let c = true; A#while c [{c = false}B]C \
|
|
#let c = true; A#while c [{c = false}B] C \
|
|
#let c = true; A #while c { c = false; "B" }C \
|
|
#let c = true; A #while c { c = false; "B" } C
|
|
|
|
---
|
|
// Spacing around for loop.
|
|
|
|
A#for _ in (none,) [B]C \
|
|
A#for _ in (none,) [B] C \
|
|
A #for _ in (none,) {"B"}C
|