typst_syntax

Module ast

source
Expand description

A typed layer over the untyped syntax tree.

The AST is rooted in the Markup node.

Structs§

  • A function call’s argument list: (12pt, y).
  • An array: (1, "hi", 12cm).
  • The auto literal.
  • A binary operation: a + b.
  • A boolean: true, false.
  • A closure: (x, y) => z.
  • The body of a code block.
  • A code block: { let x = 1; x + 2 }.
  • An if-else conditional: if x { y } else { z }.
  • A content block: [*Hi* there!].
  • A contextual expression: context text.lang.
  • An assignment expression (x, y) = (1, 2).
  • A destructuring pattern: x or (x, _, ..y).
  • A dictionary: (thickness: 3pt, pattern: dashed).
  • Emphasized content: _Emphasized_.
  • An item in an enumeration (numbered list): + ... or 1. ....
  • A mathematical equation: $x$, $ x^2 $.
  • An escape sequence: \#, \u{1F5FA}.
  • A field access: properties.age.
  • A floating-point number: 1.2, 10e-4.
  • A for loop: for x in y { z }.
  • An invocation of a function or method: f(x, y).
  • A return from a function: return, return x + 1.
  • A section heading: = Introduction.
  • An identifier: it.
  • A path to a submodule’s imported name: a.b.c.
  • Items to import from a module: a, b, c.
  • An integer: 120.
  • A keyed pair: "spacy key": true.
  • A label: <intro>.
  • A let binding: let x = 1.
  • A forced line break: \.
  • A hyperlink: https://typst.org.
  • An item in a bullet list: - ....
  • A break from a loop: break.
  • A continue in a loop: continue.
  • The syntactical root capable of representing a full parsed document.
  • The contents of a mathematical equation: x^2 + 1.
  • An alignment point in math: &.
  • A base with optional attachments in math: a_1^2.
  • Matched delimiters in math: [x + y].
  • A fraction in math: x/2
  • An identifier in math: pi.
  • Grouped primes in math: a'''.
  • A root in math: √x, ∛x or ∜x.
  • A shorthand for a unicode codepoint in math: a <= b.
  • A module import: import "utils.typ": a, b, c.
  • A module include: include "chapter1.typ".
  • A named pair: thickness: 3pt.
  • The none literal.
  • A numeric value with a unit: 12pt, 3cm, 2em, 90deg, 50%.
  • A closure’s parameters: (x, y).
  • A paragraph break, indicated by one or multiple blank lines.
  • A grouped expression: (1 + 2).
  • Raw text with optional syntax highlighting: `...`.
  • A raw delimiter in single or 3+ backticks: `.
  • A language tag at the start of raw element: typ .
  • A reference: @target, @target[..].
  • A renamed import item: a as d
  • A set rule: set text(...).
  • A shorthand for a unicode codepoint. For example, ~ for a non-breaking space or -? for a soft hyphen.
  • A show rule: show heading: it => emph(it.body).
  • A smart quote: ' or ".
  • Whitespace in markup or math. Has at most one newline in markup, as more indicate a paragraph break.
  • A spread: ..x or ..x.at(0).
  • A quoted string: "...".
  • Strong content: *Strong*.
  • An item in a term list: / Term: Details.
  • Plain text without markup.
  • A unary operation: -x.
  • An underscore: _
  • A while loop: while x { y }.

Enums§

  • An argument to a function call.
  • An item in an array.
  • The associativity of a binary operator.
  • A binary operator.
  • The kind of an element in a destructuring pattern.
  • An item in an dictionary expression.
  • An expression in markup, math or code.
  • An imported item, potentially renamed to another identifier.
  • The items that ought to be imported from a file.
  • The kind of a let binding, either a normal one or a closure.
  • A parameter to a closure.
  • The kind of a pattern.
  • A unary operator.
  • Unit of a numeric value.

Traits§