diff --git a/crates/typst/src/eval/mod.rs b/crates/typst/src/eval/mod.rs index fffedc9fa..a6fd5e172 100644 --- a/crates/typst/src/eval/mod.rs +++ b/crates/typst/src/eval/mod.rs @@ -202,9 +202,10 @@ pub fn eval_string( EvalMode::Markup => { Value::Content(root.cast::().unwrap().eval(&mut vm)?) } - EvalMode::Math => { - Value::Content(root.cast::().unwrap().eval(&mut vm)?) - } + EvalMode::Math => Value::Content((vm.items.equation)( + root.cast::().unwrap().eval(&mut vm)?, + false, + )), }; // Handle control flow. diff --git a/tests/ref/bugs/math-eval.png b/tests/ref/bugs/math-eval.png new file mode 100644 index 000000000..cdfd4cce3 Binary files /dev/null and b/tests/ref/bugs/math-eval.png differ diff --git a/tests/typ/bugs/math-eval.typ b/tests/typ/bugs/math-eval.typ new file mode 100644 index 000000000..31450b8dc --- /dev/null +++ b/tests/typ/bugs/math-eval.typ @@ -0,0 +1,5 @@ +// Evaluating a math expr should renders the same as an equation + +#eval(mode: "math", "f(a) = cases(a + b\, space space x >= 3,a + b\, space space x = 5)") + +$f(a) = cases(a + b\, space space x >= 3,a + b\, space space x = 5)$