eval
Evaluates a string as Typst code.
This function should only be used as a last resort.
Example
#eval("1 + 1") \
#eval("(1, 2, 3, 4)").len() \
#eval("*Markup!*", mode: "markup") \
参数
参数是函数的输入,它们在函数名称后面的括号中传入。
参数是函数的输入,它们在函数名称后面的括号中传入。
source
A string of Typst code to evaluate.
The code in the string cannot interact with the file system.
mode
The syntactical mode in which the string is parsed.
-
"code"
Evaluate as code, as after a hash.
-
"markup"
Evaluate as markup, like in a Typst file.
-
"math"
Evaluate as math, as in an equation.
默认:"code"
查看示例
#eval("= Heading", mode: "markup")
#eval("1_2^3", mode: "math")
scope
A scope of definitions that are made available.
默认:(:)
查看示例
#eval("x + 1", scope: (x: 2)) \
#eval(
"abc/xyz",
mode: "math",
scope: (
abc: $a + b + c$,
xyz: $x + y + z$,
),
)