Added explanation of identifiers

This commit is contained in:
Ullrich Koethe 2025-03-05 00:20:09 +01:00 committed by GitHub
parent 52cccce5bb
commit c472ee382e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,16 @@ Typst embeds a powerful scripting language. You can automate your documents and
create more sophisticated styles with code. Below is an overview over the create more sophisticated styles with code. Below is an overview over the
scripting concepts. scripting concepts.
## Identifiers
Typst uses largely the same rules to define variables, function names etc.
as most other languages, with one important exception: dashes are permitted
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)
parameter of a paragraph. In fact, this convention is more common than
underscores or camel case. Since the dash 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
are created with _functions._ To make this as convenient as possible, Typst are created with _functions._ To make this as convenient as possible, Typst