Skip to main content

Crate typst_syntax

Crate typst_syntax 

Source
Expand description

Parser and syntax tree for Typst.

Modules§

ast
Abstract Syntax Tree Interface
package
Package manifest parsing.

Structs§

DiagSpan
The span of a diagnostic message. Either from a Typst source file or from a loaded external file.
Diagnosis
Whether a node has diagnostic errors and/or warnings in it or its children.
FileId
An interned version of RootedPath.
Lines
A text buffer and metadata about lines.
LinkedChildren
An iterator over the children of a linked node.
LinkedNode
A syntax node in a context.
RangeMapper
Remaps ranges.
RootedPath
A path in a specific virtual file system root.
Source
A Typst source file containing the full source text, a mapping from byte indices to lines/columns, and the parsed syntax tree.
Span
Defines a range of text in a Typst source file.
SpanNumber
The unique number of a span within its Source. Known to be within the range of Span::FULL.
Spanned
A value with a span locating it in the source code.
SubRange
A non-empty range targeting a smaller part of a spanned section of text.
SyntaxDiagnostic
A syntactical error or warning. This is mainly used by converting it to a SourceDiagnostic during evaluation.
SyntaxNode
A node in the untyped syntax tree.
VirtualPath
A path in a virtual file system.

Enums§

DiagSpanKind
The possible kinds of a diagnostic span.
PathError
An error that can occur on construction or modification of a VirtualPath.
RealizeError
An error that can occur in VirtualPath::realize.
Side
Indicates whether the cursor is before the related byte index, or after.
SpanKind
The possible kinds of span.
SyntaxKind
A syntactical building block of a Typst file.
SyntaxMode
The syntax mode of a portion of Typst code.
Tag
A syntax highlighting tag.
VirtualRoot
The root of a virtual file system.
VirtualizeError
An error that can occur in VirtualPath::virtualize.

Functions§

highlight
Determine the highlight tag of a linked syntax node.
highlight_html
Highlight a node to an HTML code element.
is_id_continue
Whether a character can continue an identifier.
is_id_start
Whether a character can start an identifier.
is_ident
Whether a string is a valid Typst identifier.
is_newline
Whether a character is interpreted as a newline by Typst.
is_valid_label_literal_id
Returns true if this string is valid in a label literal.
link_prefix
Extracts a prefix of the text that is a link and also returns whether the parentheses and brackets in the link were balanced.
parse
Parses a source file as top-level markup.
parse_code
Parses top-level code.
parse_math
Parses top-level math.
split_newlines
Split text at newlines. These newline characters are not kept.