Revised scripting.md according to github discussion

This commit is contained in:
Ullrich Koethe 2025-03-11 19:11:48 +01:00 committed by GitHub
parent a9a8426d2d
commit 293ba5631f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,14 +8,14 @@ create more sophisticated styles with code. Below is an overview over the
scripting concepts. scripting concepts.
## Identifiers ## Identifiers
Typst uses largely the same rules to define variables, function names etc. Typst uses largely the same rules to define variables, function names etc.
as most other languages, with one important exception: dashes are permitted as most other languages, with one important exception: dashes are permitted
as part of an identifier, e.g. the [`to-absolute`]($length.to-absolute) as part of an identifier, e.g. the [`to-absolute`]($length.to-absolute)
function for a length or the [`first-line-indent`]($par.first-line-indent) function for a length or the [`first-line-indent`]($par.first-line-indent)
parameter of a paragraph. In fact, this convention is more common than parameter of a paragraph. In fact, this is the canonical convention –
underscores or camel case. Since the dash is also the symbol for subtraction, underscores or camel case are not used in "official" typst. Since the dash
a minus must be disambiguated by surrounding white space in script mode. is also the symbol for subtraction, a minus must be disambiguated by
surrounding white space in script mode.
## Expressions ## Expressions
In Typst, markup and code are fused into one. All but the most common elements In Typst, markup and code are fused into one. All but the most common elements
@ -168,7 +168,7 @@ resulting from the else's body.
``` ```
Note that the opening brace or bracket of the body must be on the same Note that the opening brace or bracket of the body must be on the same
line as the `#if` (unlike in many other languages). line as the `#if` and `else` (unlike in many other languages).
Each branch can have a code or content block as its body. Each branch can have a code or content block as its body.
- `{if condition {..}}` - `{if condition {..}}`
@ -260,8 +260,8 @@ The value in question can be either:
element was constructed. element was constructed.
**Important:** Many fields of element functions are only accessible in a **Important:** Many fields of element functions are only accessible in a
concrete context that disambiguates their meaning. Consult the chapter `context` where their concrete values are known unambiguously. Consult the
on [Context]($context) for more information. chapter on [Context]($context) for more information.
```example ```example
#let it = [= Heading] #let it = [= Heading]