summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-library/src/math/op.rs20
-rw-r--r--tests/ref/math/op.pngbin6576 -> 6762 bytes
-rw-r--r--tests/typ/math/op.typ4
3 files changed, 15 insertions, 9 deletions
diff --git a/crates/typst-library/src/math/op.rs b/crates/typst-library/src/math/op.rs
index b4c36002..8f44b3e1 100644
--- a/crates/typst-library/src/math/op.rs
+++ b/crates/typst-library/src/math/op.rs
@@ -21,7 +21,7 @@ use super::*;
pub struct OpElem {
/// The operator's text.
#[required]
- pub text: EcoString,
+ pub text: Content,
/// Whether the operator should show attachments as limits in display mode.
#[default(false)]
@@ -31,8 +31,7 @@ pub struct OpElem {
impl LayoutMath for OpElem {
#[tracing::instrument(skip(ctx))]
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- let fragment =
- ctx.layout_text(&TextElem::new(self.text().clone()).spanned(self.span()))?;
+ let fragment = ctx.layout_fragment(self.text())?;
ctx.push(
FrameFragment::new(ctx, fragment.into_frame())
.with_class(MathClass::Large)
@@ -49,12 +48,15 @@ impl LayoutMath for OpElem {
macro_rules! ops {
($($name:ident $(: $value:literal)? $(($tts:tt))?),* $(,)?) => {
pub(super) fn define(math: &mut Scope) {
- $(math.define(
- stringify!($name),
- OpElem::new(ops!(@name $name $(: $value)?).into())
- .with_limits(ops!(@limit $($tts)*))
- .pack()
- );)*
+ $({
+ let operator = EcoString::from(ops!(@name $name $(: $value)?));
+ math.define(
+ stringify!($name),
+ OpElem::new(TextElem::new(operator).into())
+ .with_limits(ops!(@limit $($tts)*))
+ .pack()
+ );
+ })*
let dif = |d| {
HElem::new(THIN.into()).with_weak(true).pack()
diff --git a/tests/ref/math/op.png b/tests/ref/math/op.png
index 863c6684..089e5168 100644
--- a/tests/ref/math/op.png
+++ b/tests/ref/math/op.png
Binary files differ
diff --git a/tests/typ/math/op.typ b/tests/typ/math/op.typ
index 2a0f84fc..14e1c6e6 100644
--- a/tests/typ/math/op.typ
+++ b/tests/typ/math/op.typ
@@ -24,3 +24,7 @@ $ op("myop", limits: #false)_(x:=1) x \
---
// Test styled operator.
$ bold(op("bold", limits: #true))_x y $
+
+---
+// With non-text content
+$ op(#underline[ul]) a $