summaryrefslogtreecommitdiff
path: root/crates/typst-eval
diff options
context:
space:
mode:
authorIan Wrzesinski <wrzian@umich.edu>2024-07-20 21:21:53 -0500
committerIan Wrzesinski <wrzian@umich.edu>2025-01-23 16:28:29 -0500
commit0b8b7d0f233f748a5c12d1b8e31f657803122eba (patch)
treebbb904cb876ad5741f3e8a46758363af70af10e4 /crates/typst-eval
parent2d33393df967bbe55646b839e188c04380d823fe (diff)
Just add MathText SyntaxKind
Diffstat (limited to 'crates/typst-eval')
-rw-r--r--crates/typst-eval/src/code.rs1
-rw-r--r--crates/typst-eval/src/math.rs14
2 files changed, 14 insertions, 1 deletions
diff --git a/crates/typst-eval/src/code.rs b/crates/typst-eval/src/code.rs
index 34373fd4..2baf4ea9 100644
--- a/crates/typst-eval/src/code.rs
+++ b/crates/typst-eval/src/code.rs
@@ -99,6 +99,7 @@ impl Eval for ast::Expr<'_> {
Self::Term(v) => v.eval(vm).map(Value::Content),
Self::Equation(v) => v.eval(vm).map(Value::Content),
Self::Math(v) => v.eval(vm).map(Value::Content),
+ Self::MathText(v) => v.eval(vm).map(Value::Content),
Self::MathIdent(v) => v.eval(vm),
Self::MathShorthand(v) => v.eval(vm),
Self::MathAlignPoint(v) => v.eval(vm).map(Value::Content),
diff --git a/crates/typst-eval/src/math.rs b/crates/typst-eval/src/math.rs
index 51dc0a3d..f93f147e 100644
--- a/crates/typst-eval/src/math.rs
+++ b/crates/typst-eval/src/math.rs
@@ -5,7 +5,7 @@ use typst_library::math::{
AlignPointElem, AttachElem, FracElem, LrElem, PrimesElem, RootElem,
};
use typst_library::text::TextElem;
-use typst_syntax::ast::{self, AstNode};
+use typst_syntax::ast::{self, AstNode, MathTextKind};
use crate::{Eval, Vm};
@@ -20,6 +20,18 @@ impl Eval for ast::Math<'_> {
}
}
+impl Eval for ast::MathText<'_> {
+ type Output = Content;
+
+ fn eval(self, _: &mut Vm) -> SourceResult<Self::Output> {
+ match self.get() {
+ // TODO: change to `SymbolElem` when added
+ MathTextKind::Character(c) => Ok(Value::Symbol(Symbol::single(c)).display()),
+ MathTextKind::Number(text) => Ok(TextElem::packed(text.clone())),
+ }
+ }
+}
+
impl Eval for ast::MathIdent<'_> {
type Output = Value;