typst_syntax/
lib.rs

1//! Parser and syntax tree for Typst.
2
3pub mod ast;
4pub mod package;
5
6mod file;
7mod highlight;
8mod kind;
9mod lexer;
10mod lines;
11mod node;
12mod parser;
13mod path;
14mod reparser;
15mod set;
16mod source;
17mod span;
18
19pub use self::file::FileId;
20pub use self::highlight::{Tag, highlight, highlight_html};
21pub use self::kind::SyntaxKind;
22pub use self::lexer::{
23    is_id_continue, is_id_start, is_ident, is_newline, is_valid_label_literal_id,
24    link_prefix, split_newlines,
25};
26pub use self::lines::Lines;
27pub use self::node::{LinkedChildren, LinkedNode, Side, SyntaxError, SyntaxNode};
28pub use self::parser::{parse, parse_code, parse_math};
29pub use self::path::VirtualPath;
30pub use self::source::Source;
31pub use self::span::{Span, Spanned};
32
33use self::lexer::Lexer;
34use self::parser::{reparse_block, reparse_markup};
35
36/// The syntax mode of a portion of Typst code.
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
38pub enum SyntaxMode {
39    /// Text and markup, as in the top level.
40    Markup,
41    /// Math atoms, operators, etc., as in equations.
42    Math,
43    /// Keywords, literals and operators, as after hashes.
44    Code,
45}