summaryrefslogtreecommitdiff
path: root/src/syntax/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-02-13 21:58:49 +0100
committerLaurenz <laurmaedje@gmail.com>2020-02-13 21:58:49 +0100
commit1658b00282b631fb5218f477ea7f45f925644cea (patch)
tree13a0f51f335e687c363a5afb9cc73993a69489cc /src/syntax/mod.rs
parent60099aed50b89daef29543c4700470e566c48798 (diff)
New syntax features 👔
- Forced line breaks with backslash followed by whitespace - (Multline) raw text in backticks - Set font class fallbacks with [font.family] (e.g. [font.family: monospace=("CMU Typewriter Text")]) - More sophisticated procedure to find end of function, which accounts for comments, strings, raw text and nested functions (this is a mix of a feature and a bug fix)
Diffstat (limited to 'src/syntax/mod.rs')
-rw-r--r--src/syntax/mod.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs
index c3a57ee6..f7321c77 100644
--- a/src/syntax/mod.rs
+++ b/src/syntax/mod.rs
@@ -62,15 +62,17 @@ pub enum Node {
/// Whitespace containing less than two newlines.
Space,
/// Whitespace with more than two newlines.
- Newline,
+ Parbreak,
+ /// A forced line break.
+ Linebreak,
/// Plain text.
Text(String),
+ /// Lines of raw text.
+ Raw(Vec<String>),
/// Italics were enabled / disabled.
ToggleItalic,
/// Bolder was enabled / disabled.
ToggleBolder,
- /// Monospace was enabled / disabled.
- ToggleMonospace,
/// A submodel, typically a function invocation.
Model(Box<dyn Model>),
}
@@ -80,11 +82,12 @@ impl PartialEq for Node {
use Node::*;
match (self, other) {
(Space, Space) => true,
- (Newline, Newline) => true,
+ (Parbreak, Parbreak) => true,
+ (Linebreak, Linebreak) => true,
(Text(a), Text(b)) => a == b,
+ (Raw(a), Raw(b)) => a == b,
(ToggleItalic, ToggleItalic) => true,
(ToggleBolder, ToggleBolder) => true,
- (ToggleMonospace, ToggleMonospace) => true,
(Model(a), Model(b)) => a == b,
_ => false,
}
@@ -107,6 +110,7 @@ pub enum Decoration {
/// ^^^^^^
/// ```
InvalidFuncName,
+
/// A key of a keyword argument:
/// ```typst
/// [box: width=5cm]
@@ -119,12 +123,11 @@ pub enum Decoration {
/// ^^^^ ^^^^^
/// ```
ObjectKey,
+
/// An italic word.
Italic,
/// A bold word.
Bold,
- /// A monospace word.
- Monospace,
}
impl dyn Model {