summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/color.rs6
-rw-r--r--src/lib.rs4
-rw-r--r--src/paper.rs2
-rw-r--r--tools/support/typst.tmLanguage.json50
4 files changed, 20 insertions, 42 deletions
diff --git a/src/color.rs b/src/color.rs
index 66810537..35b90e8a 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 c8d41317..d4a73ed4 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 bbe07803..58d87be1 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<Linear> {
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 867f2109..58c9f893 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,26 +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",
- "end": "\n|(?=])|(?<=}|])",
- "beginCaptures": {
- "0": { "name": "keyword.control.conditional.typst" },
- "1": { "name": "punctuation.definition.keyword.typst" }
- },
- "patterns": [{ "include": "#code" }]
- },
- {
- "begin": "(#)else",
+ "begin": "(#)(if|else)\\b",
"end": "\n|(?=])|(?<=}|])",
"beginCaptures": {
"0": { "name": "keyword.control.conditional.typst" },
@@ -161,16 +142,7 @@
"patterns": [{ "include": "#code" }]
},
{
- "begin": "(#)for",
- "end": "\n|(?=])|(?<=}|])",
- "beginCaptures": {
- "0": { "name": "keyword.control.typst" },
- "1": { "name": "punctuation.definition.keyword.typst" }
- },
- "patterns": [{ "include": "#code" }]
- },
- {
- "begin": "(#)while",
+ "begin": "(#)(for|while)\\b",
"end": "\n|(?=])|(?<=}|])",
"beginCaptures": {
"0": { "name": "keyword.control.typst" },
@@ -179,7 +151,7 @@
"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": "\\+|\\*|/|(?<![[:alpha:]_][[:alnum:]_-]*)-(?![:alnum:]_-]*[[:alpha:]_])"
+ "match": "\\+|\\*!?|/|(?<![[:alpha:]_][[:alnum:]_-]*)-(?![:alnum:]_-]*[[:alpha:]_])"
},
{
"name": "keyword.operator.word.typst",
@@ -250,11 +222,11 @@
{
"comment": "Function name",
"name": "entity.name.function.typst",
- "match": "\\b[[:alpha:]_][[:alnum:]_-]*(?=\\[|\\()"
+ "match": "\\b[[:alpha:]_][[:alnum:]_-]*!?(?=\\[|\\()"
},
{
"comment": "Function arguments",
- "begin": "(?<=\\b[[:alpha:]_][[:alnum:]_-]*)\\(",
+ "begin": "(?<=\\b[[:alpha:]_][[:alnum:]_-]*!?)\\(",
"end": "\\)",
"captures": { "0": { "name": "punctuation.definition.group.typst" } },
"patterns": [{ "include": "#arguments" }]