summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-21 17:12:16 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-21 17:12:16 +0100
commitdd9c323941260a1d08d5113dbefa023713f553da (patch)
tree48c813c01a83f5c6ca67ebbabd041c0298eb0da2 /src/model
parentc28d2130ddda3ae9b25cc16c3015087990ccb6e9 (diff)
Show with set
Diffstat (limited to 'src/model')
-rw-r--r--src/model/eval.rs6
-rw-r--r--src/model/styles.rs3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/model/eval.rs b/src/model/eval.rs
index 79ad0815..b7df12aa 100644
--- a/src/model/eval.rs
+++ b/src/model/eval.rs
@@ -851,7 +851,11 @@ impl Eval for ast::ShowRule {
let transform = self.transform();
let span = transform.span();
- let transform = transform.eval(vm)?.cast::<Transform>().at(span)?;
+
+ let transform = match transform {
+ ast::Expr::Set(set) => Transform::Style(set.eval(vm)?),
+ expr => expr.eval(vm)?.cast::<Transform>().at(span)?,
+ };
Ok(Recipe { span, selector, transform })
}
diff --git a/src/model/styles.rs b/src/model/styles.rs
index 4195d3e1..30db00bd 100644
--- a/src/model/styles.rs
+++ b/src/model/styles.rs
@@ -491,6 +491,8 @@ pub enum Transform {
Content(Content),
/// A function to apply to the match.
Func(Func),
+ /// Apply styles to the content.
+ Style(StyleMap),
}
impl Transform {
@@ -512,6 +514,7 @@ impl Transform {
}
Ok(result?.display())
}
+ Transform::Style(styles) => Ok(content.styled_with_map(styles.clone())),
}
}
}