diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/eval.rs | 6 | ||||
| -rw-r--r-- | src/model/styles.rs | 3 | ||||
| -rw-r--r-- | src/syntax/incremental.rs | 2 |
3 files changed, 9 insertions, 2 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())), } } } diff --git a/src/syntax/incremental.rs b/src/syntax/incremental.rs index 1087bb79..6c9145a2 100644 --- a/src/syntax/incremental.rs +++ b/src/syntax/incremental.rs @@ -458,7 +458,7 @@ mod tests { test(r#"a ```typst hello``` b"#, 16 .. 17, "", 0 .. 18); test(r#"a ```typst hello```"#, 16 .. 17, "", 0 .. 18); test("#for", 4 .. 4, "//", 0 .. 6); - test("#show a: f as b..", 16..16, "c", 0..18); + test("#show f: a => b..", 16..16, "c", 0..18); test("a\n#let \nb", 7 .. 7, "i", 2 .. 9); test("a\n#for i \nb", 9 .. 9, "in", 2 .. 12); test("a~https://fun/html", 13..14, "n", 0..18); |
