diff --git a/src/color.rs b/src/color.rs index 668105377..35b90e8ad 100644 --- a/src/color.rs +++ b/src/color.rs @@ -40,6 +40,12 @@ pub struct RgbaColor { } impl RgbaColor { + /// Black color. + pub const BLACK: Self = Self { r: 0, g: 0, b: 0, a: 255 }; + + /// White color. + pub const WHITE: Self = Self { r: 255, g: 255, b: 255, a: 255 }; + /// Constructs a new RGBA color. pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self { Self { r, g, b, a } diff --git a/src/lib.rs b/src/lib.rs index c8d413176..d4a73ed4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,8 +12,8 @@ //! This produces a [layout tree], a high-level, fully styled representation. //! The nodes of this tree are self-contained and order-independent and thus //! much better suited for layouting than the syntax tree. -//! - **Layouting:** Next, the tree is to [layouted] into a portable version of -//! the typeset document. The output of this is a vector of [`Frame`]s +//! - **Layouting:** Next, the tree is [layouted] into a portable version of the +//! typeset document. The output of this is a vector of [`Frame`]s //! (corresponding to pages), ready for exporting. //! - **Exporting:** The finished layout can be exported into a supported //! format. Submodules for these formats are located in the [export] module. diff --git a/src/paper.rs b/src/paper.rs index bbe078031..58d87be16 100644 --- a/src/paper.rs +++ b/src/paper.rs @@ -39,7 +39,7 @@ impl PaperClass { /// The default margins for this page class. pub fn default_margins(self) -> Sides { let f = |r| Relative::new(r).into(); - let s = |l, r, t, b| Sides::new(f(l), f(r), f(t), f(b)); + let s = |l, t, r, b| Sides::new(f(l), f(t), f(r), f(b)); match self { Self::Custom => s(0.1190, 0.0842, 0.1190, 0.0842), Self::Base => s(0.1190, 0.0842, 0.1190, 0.0842), diff --git a/tools/support/typst.tmLanguage.json b/tools/support/typst.tmLanguage.json index 867f21098..58c9f893f 100644 --- a/tools/support/typst.tmLanguage.json +++ b/tools/support/typst.tmLanguage.json @@ -114,16 +114,16 @@ }, { "name": "keyword.control.typst", - "match": "(#)(break|continue|return)", + "match": "(#)(break|continue|return)\\b", "captures": { "1": { "name": "punctuation.definition.keyword.typst" } } }, { "name": "keyword.other.typst", - "match": "(#)from", + "match": "(#)(from|in)\\b", "captures": { "1": { "name": "punctuation.definition.keyword.typst" } } }, { - "begin": "(#)pub", + "begin": "(#)(pub|let)\\b", "end": "\n|(;)|(?=])|(?<=}|])", "beginCaptures": { "0": { "name": "keyword.other.typst" }, @@ -133,17 +133,7 @@ "patterns": [{ "include": "#code" }] }, { - "begin": "(#)let", - "end": "\n|;|(?=])|(?<=}|])", - "beginCaptures": { - "0": { "name": "keyword.other.typst" }, - "1": { "name": "punctuation.definition.keyword.typst" } - }, - "endCaptures": { "1": { "name": "punctuation.terminator.statement.typst" } }, - "patterns": [{ "include": "#code" }] - }, - { - "begin": "(#)if", + "begin": "(#)(if|else)\\b", "end": "\n|(?=])|(?<=}|])", "beginCaptures": { "0": { "name": "keyword.control.conditional.typst" }, @@ -152,16 +142,7 @@ "patterns": [{ "include": "#code" }] }, { - "begin": "(#)else", - "end": "\n|(?=])|(?<=}|])", - "beginCaptures": { - "0": { "name": "keyword.control.conditional.typst" }, - "1": { "name": "punctuation.definition.keyword.typst" } - }, - "patterns": [{ "include": "#code" }] - }, - { - "begin": "(#)for", + "begin": "(#)(for|while)\\b", "end": "\n|(?=])|(?<=}|])", "beginCaptures": { "0": { "name": "keyword.control.typst" }, @@ -170,16 +151,7 @@ "patterns": [{ "include": "#code" }] }, { - "begin": "(#)while", - "end": "\n|(?=])|(?<=}|])", - "beginCaptures": { - "0": { "name": "keyword.control.typst" }, - "1": { "name": "punctuation.definition.keyword.typst" } - }, - "patterns": [{ "include": "#code" }] - }, - { - "begin": "(#)import", + "begin": "(#)import\\b", "end": "\n|(?=])", "beginCaptures": { "0": { "name": "keyword.control.import.typst" }, @@ -190,12 +162,12 @@ { "comment": "Function name", "name": "entity.name.function.typst", - "match": "((#)[[:alpha:]_][[:alnum:]_-]*)(?=\\[|\\()", + "match": "((#)[[:alpha:]_][[:alnum:]_-]*!?)(?=\\[|\\()", "captures": { "2": { "name": "punctuation.definition.function.typst" } } }, { "comment": "Function arguments", - "begin": "(?<=#[[:alpha:]_][[:alnum:]_-]*)\\(", + "begin": "(?<=#[[:alpha:]_][[:alnum:]_-]*!?)\\(", "end": "\\)", "captures": { "0": { "name": "punctuation.definition.group.typst" } }, "patterns": [{ "include": "#arguments" }] @@ -232,7 +204,7 @@ }, { "name": "keyword.operator.arithmetic.typst", - "match": "\\+|\\*|/|(?