From 62361b4127c39fc1b165b81f24f52b14ddaa41db Mon Sep 17 00:00:00 2001 From: Leedehai <18319900+Leedehai@users.noreply.github.com> Date: Tue, 25 Apr 2023 05:24:07 -0400 Subject: Support indices preceding the base symbol, revamping #699 (#825) Breaking change: abbreviate attach() attachment params, top -> t, bottom -> b --- src/eval/library.rs | 14 ++++++++++++-- src/eval/mod.rs | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/eval') diff --git a/src/eval/library.rs b/src/eval/library.rs index 0c635864..a92d8bd1 100644 --- a/src/eval/library.rs +++ b/src/eval/library.rs @@ -87,8 +87,18 @@ pub struct LangItems { /// Matched delimiters in math: `[x + y]`. pub math_delimited: fn(open: Content, body: Content, close: Content) -> Content, /// A base with optional attachments in math: `a_1^2`. - pub math_attach: - fn(base: Content, bottom: Option, top: Option) -> Content, + #[allow(clippy::type_complexity)] + pub math_attach: fn( + base: Content, + // Positioned smartly. + top: Option, + bottom: Option, + // Fixed positions. + topleft: Option, + bottomleft: Option, + topright: Option, + bottomright: Option, + ) -> Content, /// A base with an accent: `arrow(x)`. pub math_accent: fn(base: Content, accent: char) -> Content, /// A fraction in math: `x/2`. diff --git a/src/eval/mod.rs b/src/eval/mod.rs index d8f49d66..d2ca0e74 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -708,9 +708,9 @@ impl Eval for ast::MathAttach { #[tracing::instrument(name = "MathAttach::eval", skip_all)] fn eval(&self, vm: &mut Vm) -> SourceResult { let base = self.base().eval_display(vm)?; - let bottom = self.bottom().map(|expr| expr.eval_display(vm)).transpose()?; let top = self.top().map(|expr| expr.eval_display(vm)).transpose()?; - Ok((vm.items.math_attach)(base, bottom, top)) + let bottom = self.bottom().map(|expr| expr.eval_display(vm)).transpose()?; + Ok((vm.items.math_attach)(base, top, bottom, None, None, None, None)) } } -- cgit v1.2.3