TypstDocumentation

toml

Reads structured data from a TOML file.

The file must contain a valid TOML table. TOML tables will be converted into Typst dictionaries, and TOML arrays will be converted into Typst arrays. Strings, booleans and datetimes will be converted into the Typst equivalents and numbers will be converted to floats or integers depending on whether they are whole numbers.

The TOML file in the example consists of a table with the keys title, version, and authors.

Example

#let details = toml("details.toml")

Title: #details.title \
Version: #details.version \
Authors: #(details.authors
  .join(", ", last: " and "))
Preview

Parameters
Question mark

toml() -> any

path
str
RequiredPositional
Question mark

Path to a TOML file.

Definitions
Question mark

decode

Reads structured data from a TOML string/bytes.

toml.decode() -> any

data
str or bytes
RequiredPositional
Question mark

TOML data.

encode

Encodes structured data into a TOML string.

toml.encode() -> str

value
any
RequiredPositional
Question mark

Value to be encoded.

pretty

Whether to pretty-print the resulting TOML.

Default: true