summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLeedehai <18319900+Leedehai@users.noreply.github.com>2023-04-25 05:24:07 -0400
committerGitHub <noreply@github.com>2023-04-25 11:24:07 +0200
commit62361b4127c39fc1b165b81f24f52b14ddaa41db (patch)
tree830f1ef69e77c9e9fbab2337f05136fa69ed0755 /src/eval
parentfb99090208c9aface707f9d4526f411fcb67f705 (diff)
Support indices preceding the base symbol, revamping #699 (#825)
Breaking change: abbreviate attach() attachment params, top -> t, bottom -> b
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/library.rs14
-rw-r--r--src/eval/mod.rs4
2 files changed, 14 insertions, 4 deletions
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<Content>, top: Option<Content>) -> Content,
+ #[allow(clippy::type_complexity)]
+ pub math_attach: fn(
+ base: Content,
+ // Positioned smartly.
+ top: Option<Content>,
+ bottom: Option<Content>,
+ // Fixed positions.
+ topleft: Option<Content>,
+ bottomleft: Option<Content>,
+ topright: Option<Content>,
+ bottomright: Option<Content>,
+ ) -> 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<Self::Output> {
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))
}
}