{"route":"/en-US-v0.13.1/reference/data-loading/toml/","title":"TOML","description":"Documentation for the `toml` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-source","name":"source","children":[]}]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-decode","name":"Decode TOML","children":[{"id":"definitions-decode-data","name":"data","children":[]}]},{"id":"definitions-encode","name":"Encode TOML","children":[{"id":"definitions-encode-value","name":"value","children":[]},{"id":"definitions-encode-pretty","name":"pretty","children":[]}]}]}],"body":{"kind":"func","content":{"path":[],"name":"toml","title":"TOML","keywords":[],"oneliner":"Reads structured data from a TOML file.","element":false,"contextual":false,"deprecation":null,"details":"<p>Reads structured data from a TOML file.</p>\n<p>The file must contain a valid TOML table. TOML tables will be converted into\nTypst dictionaries, and TOML arrays will be converted into Typst arrays.\nStrings, booleans and datetimes will be converted into the Typst equivalents\nand numbers will be converted to floats or integers depending on whether\nthey are whole numbers.</p>\n<p>The TOML file in the example consists of a table with the keys <code>title</code>,\n<code>version</code>, and <code>authors</code>.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> details <span class=\"typ-op\">=</span> <span class=\"typ-func\">toml</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;details.toml&quot;</span><span class=\"typ-punct\">)</span>\n\nTitle: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">details</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">title</span> <span class=\"typ-escape\">\\</span>\nVersion: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">details</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">version</span> <span class=\"typ-escape\">\\</span>\nAuthors: <span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span>details<span class=\"typ-punct\">.</span>authors\n  <span class=\"typ-punct\">.</span><span class=\"typ-func\">join</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;, &quot;</span><span class=\"typ-punct\">,</span> last<span class=\"typ-punct\">:</span> <span class=\"typ-str\">&quot; and &quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/7f6e9fac705651fafb6c8a26435ab058.png\" alt=\"Preview\"></div></div>","example":null,"self":false,"params":[{"name":"source","details":"<p>A <a href=\"/en-US-v0.13.1/reference/syntax/#paths\">path</a> to a TOML file or raw TOML bytes.</p>","example":null,"types":["str","bytes"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["any"],"scope":[{"path":["toml"],"name":"decode","title":"Decode TOML","keywords":[],"oneliner":"Reads structured data from a TOML string/bytes.","element":false,"contextual":false,"deprecation":"`toml.decode` is deprecated, directly pass bytes to `toml` instead","details":"<p>Reads structured data from a TOML string/bytes.</p>","example":null,"self":false,"params":[{"name":"data","details":"<p>TOML data.</p>","example":null,"types":["str","bytes"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["any"],"scope":[]},{"path":["toml"],"name":"encode","title":"Encode TOML","keywords":[],"oneliner":"Encodes structured data into a TOML string.","element":false,"contextual":false,"deprecation":null,"details":"<p>Encodes structured data into a TOML string.</p>","example":null,"self":false,"params":[{"name":"value","details":"<p>Value to be encoded.</p>","example":null,"types":["any"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"pretty","details":"<p>Whether to pretty-print the resulting TOML.</p>","example":null,"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">true</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["str"],"scope":[]}]}}}