Development build 586e1bd4
Typst文档简体中文版v0.15.1 + dev 586e1bd4

eval自始可用Go to source

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") \

参数
Question mark

eval() → any

source
str
必需参数
Question mark
位置参数
Question mark

A string of Typst code to evaluate.

mode默认值:"code"

The syntactical mode in which the string is parsed.

Expand展开示例
#eval("= Heading", mode: "markup") #eval("1_2^3", mode: "math")
VariantDetails
"markup"Evaluate as markup, as in a Typst file.
"math"Evaluate as math, as in an equation.
"code"Evaluate as code, as after a hash.

scope默认值:(:)

A scope of definitions that are made available.

Expand展开示例
#eval("x + 1", scope: (x: 2)) \ #eval( "abc/xyz", mode: "math", scope: ( abc: $a + b + c$, xyz: $x + y + z$, ), )