use unicode_math_class::MathClass;
use crate::diag::SourceResult;
use crate::foundations::{elem, Content, Packed, StyleChain};
use crate::math::{EquationElem, LayoutMath, Limits, MathContext};
#[elem(LayoutMath)]
pub struct ClassElem {
#[required]
pub class: MathClass,
#[required]
pub body: Content,
}
impl LayoutMath for Packed<ClassElem> {
#[typst_macros::time(name = "math.class", span = self.span())]
fn layout_math(&self, ctx: &mut MathContext, styles: StyleChain) -> SourceResult<()> {
let class = *self.class();
let style = EquationElem::set_class(Some(class)).wrap();
let mut fragment = ctx.layout_into_fragment(self.body(), styles.chain(&style))?;
fragment.set_class(class);
fragment.set_limits(Limits::for_class(class));
ctx.push(fragment);
Ok(())
}
}