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

toml0.3.0起可用Go to source

Reads structured data from a TOML file.

The file must contain a valid TOML table. The TOML values will be converted into corresponding Typst values as listed in the table below.

The function returns a dictionary representing the TOML table.

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

Conversion details

First of all, TOML documents are tables. Other values must be put in a table to be encoded or decoded.

TOML valueConverted into Typst
stringstr
integerint
floatfloat
booleanbool
datetimedatetime
arrayarray
tabledictionary
Typst valueConverted into TOML
types that can be converted from TOMLcorresponding TOML value
noneignored
bytesstring via repr
symbolstring
contenta table describing the content
other types (length, etc.)string via repr

Notes

参数
Question mark

source
str or path or bytes
必需参数
Question mark
位置参数
Question mark

A path to a TOML file or raw TOML bytes.

定义
Question mark

encode0.8.0起可用Go to source

Encodes structured data into a TOML string.

toml.encode() → str

value
dictionary
必需参数
Question mark
位置参数
Question mark

Value to be encoded.

TOML documents are tables. Therefore, only dictionaries are suitable.

pretty默认值:true

Whether to pretty-print the resulting TOML.