跳到主要内容

get-input

Returns input given to the compiler.

Anything Typst knows is parsed as Typst: red is a colour, left an alignment, 3 and 2em numbers, true/false/none/auto keywords, and dictionaries, arrays and function calls all work. A single word Typst does not know becomes a string, so --input export-mode=handout needs no shell quoting.

Example: typst compile --input export-mode=handout myslide.typ
Then in the code you can do: #let export-mode = utils.get-input(key: "export-mode")

Example 2: typst compile FILE --input config='("foo": 1, "bar": [1, 2, 3], "baz": ("nested": 4))'

You may also provide no key to get the entire inputs dictionary with parsed values: #let inputs = utils.get-input()

Parameters

key : str | none    default: none​

The input key to retrieve. If none, returns the entire inputs dictionary with parsed values.

Returns: any