ronantakizawa/codereview-bench huggingface dataset:
Repository: typst/typst
File: crates/typst-library/src/visualize/gradient.rs (Rust)

Code before:
        .map(|(i, stop)| {
            let offset = i as f64 / (stops.len() - 1) as f64;
            (stop.v.color, Ratio::new(offset))
        })
        .collect())
}

/// Sample the stops at a given position.
fn sample_stops(stops: &[(Color, Ratio)], mixing_space: ColorSpace, t: f64) -> Color {
    assert!(!stops.is_empty(), "Cannot sample from gradient with no stops");

    let t = t.clamp(0.0, 1.0);
    let mut j = stops.partition_point(|(_, ratio)| ratio.get() < t);

    if j == 0 {
        while stops.get(j + 1).is_some_and(|(_, r)| r.is_zero()) {
            j += 1;
        }
        return stops[j].0;
    }
    if j == stops.len() {
        while j > 0 && stops[j].1.is_one() {
            j -= 1;
        }
        return stops[j].0;
    }

    let (col_0, pos_0) = stops[j - 1];
    let (col_1, pos_1) = stops[j];
    debug_assert!(pos_0 < pos_1);
    debug_assert!(pos_0.get() <= t);
    debug_assert!(t <= pos_1.get());
    let t = (t - pos_0.get()) / (pos_1.get() - pos_0.get());

    Color::mix_iter(
        [WeightedColor::new(col_0, 1.0 - t), WeightedColor::new(col_1, t)],
        mixing_space,
    )
    .unwrap()
}


Review comment (suggestion):
Since the partition checks for `< t` and the last point is required to be `1` this if statement seems to be redundant, because `1 < 1` will always return `false`.
The loop is also redundant, because we will always land at the lower end of a chunk with equal ratios. And it would panic because it would index the array at `stops.len()` when the condition is initially checked.

Code after:
        .map(|(i, stop)| {
            let offset = i as f64 / (stops.len() - 1) as f64;
            (stop.v.color, Ratio::new(offset))
        })
        .collect())
}

/// Sample the stops at a given position.
fn sample_stops(stops: &[(Color, Ratio)], mixing_space: ColorSpace, t: f64) -> Color {
    let t = t.clamp(0.0, 1.0);
    let mut j = stops.partition_point(|(_, ratio)| ratio.get() < t);

    if j == 0 {
        while stops.get(j + 1).is_some_and(|(_, r)| r.is_zero()) {
            j += 1;
        }
        return stops[j].0;
    }

    let (col_0, pos_0) = stops[j - 1];
    let (col_1, pos_1) = stops[j];
    let t = (t - pos_0.get()) / (pos_1.get() - pos_0.get());

    Color::mix_iter(
        [WeightedColor::new(col_0, 1.0 - t), WeightedColor::new(col_1, t)],
        mixing_space,
    )
    .unwrap()
}
Repository: typst/typst
File: crates/typst-layout/src/math/fragment.rs (Rust)

Code before:
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

/// A fragment of a glyph in math mode.
#[derive(Clone)]
pub struct GlyphFragment {
    /// A unique id.
    pub id: GlyphId,

    /// The base character.
    pub c: char,

    /// A font family descriptor or priority list of font family descriptor.
    ///
    /// This works much akin to how fonts are specified for [TextElem], but for modification
    /// a show rule must be used.
    ///
    /// ```example
    /// #show math.equation: set text(font: "Fira Math")
    /// $ f i r a m a t h $
    /// ```
    pub font: Font,

    /// An [ISO 639-1/2/3 language code.](https://en.wikipedia.org/wiki/ISO_639)
    ///
    /// See [TextElem]
    pub lang: Lang,

    /// An [ISO 3166-1 alpha-2 region code.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
    ///
    /// See [TextElem]
    pub region: Option<Region>,

    /// The glyph fill paint.
    ///
    /// ```example
    /// #show math.equation: set text(fill: red)
    /// $ r e d $
    /// ```
    pub fill: Paint,

    /// How to stroke the text.
    ///
    /// ```example
    /// #show math.equation: set text(stroke: red + 0.5pt)

Review comment (suggestion):
I'm not sure how useful this would be given that it isn't user facing and won't be rendered (like the examples in the docs) anywhere.

Code after:
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

#[derive(Clone)]
pub struct GlyphFragment {
    pub id: GlyphId,
    pub c: char,
    pub font: Font,
    pub lang: Lang,
    pub region: Option<Region>,
    pub fill: Paint,
    pub stroke: Option<FixedStroke>,
    pub shift: Abs,
    pub width: Abs,
    pub ascent: Abs,
    pub descent: Abs,
    pub italics_correction: Abs,
    pub accent_attach: Abs,
    pub font_size: Abs,
    pub class: MathClass,
    pub math_size: MathSize,
    pub span: Span,
    pub modifiers: FrameModifiers,
    pub limits: Limits,
    pub extended_shape: bool,
}

impl GlyphFragment {
    pub fn new(ctx: &MathContext, styles: StyleChain, c: char, span: Span) -> Self {
        let id = ctx.ttf.glyph_index(c).unwrap_or_default();
        let id = Self::adjust_glyph_index(ctx, id);
        Self::with_id(ctx, styles, c, id, span)
    }

    pub fn try_new(
        ctx: &MathContext,
        styles: StyleChain,
        c: char,
        span: Span,
    ) -> Option<Self> {
        let id = ctx.ttf.glyph_index(c)?;
        let id = Self::adjust_glyph_index(ctx, id);
        Some(Self::with_id(ctx, styles, c, id, span))
    }
Repository: typst/typst
File: crates/typst-layout/src/math/fragment.rs (Rust)

Code before:
                    .unwrap_or_default()
            }
            _ => Abs::zero(),
        }
    }
}

impl From<GlyphFragment> for MathFragment {
    fn from(glyph: GlyphFragment) -> Self {
        Self::Glyph(glyph)
    }
}

impl From<VariantFragment> for MathFragment {
    fn from(variant: VariantFragment) -> Self {
        Self::Variant(variant)
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

/// A fragment of a glyph in math mode.
#[derive(Clone)]
pub struct GlyphFragment {
    /// A unique id.
    pub id: GlyphId,

    /// The base character.
    pub c: char,

    /// A font family descriptor or priority list of font family descriptor.
    ///
    /// This works much akin to how fonts are specified for [TextElem], but for modification
    /// a show rule must be used.
    ///
    /// ```example
    /// #show math.equation: set text(font: "Fira Math")
    /// $ f i r a m a t h $
    /// ```
    pub font: Font,

    /// An [ISO 639-1/2/3 language code.](https://en.wikipedia.org/wiki/ISO_639)
    ///
    /// See [TextElem]
    pub lang: Lang,

    /// An [ISO 3166-1 alpha-2 region code.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)

Review comment (suggestion):
```suggestion
/// A single glyph in math.
```
Currently it reads like this struct defines a part of a glyph, as opposed to a fragment in math which is a single glyph.

Code after:
                    .unwrap_or_default()
            }
            _ => Abs::zero(),
        }
    }
}

impl From<GlyphFragment> for MathFragment {
    fn from(glyph: GlyphFragment) -> Self {
        Self::Glyph(glyph)
    }
}

impl From<VariantFragment> for MathFragment {
    fn from(variant: VariantFragment) -> Self {
        Self::Variant(variant)
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

#[derive(Clone)]
pub struct GlyphFragment {
    pub id: GlyphId,
    pub c: char,
    pub font: Font,
    pub lang: Lang,
    pub region: Option<Region>,
    pub fill: Paint,
    pub stroke: Option<FixedStroke>,
    pub shift: Abs,
    pub width: Abs,
    pub ascent: Abs,
    pub descent: Abs,
    pub italics_correction: Abs,
    pub accent_attach: Abs,
    pub font_size: Abs,
    pub class: MathClass,
    pub math_size: MathSize,
    pub span: Span,
    pub modifiers: FrameModifiers,
    pub limits: Limits,
    pub extended_shape: bool,
}

impl GlyphFragment {
    pub fn new(ctx: &MathContext, styles: StyleChain, c: char, span: Span) -> Self {
Repository: typst/typst
File: crates/typst-layout/src/math/fragment.rs (Rust)

Code before:
        Self::Glyph(glyph)
    }
}

impl From<VariantFragment> for MathFragment {
    fn from(variant: VariantFragment) -> Self {
        Self::Variant(variant)
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

/// A fragment of a glyph in math mode.
#[derive(Clone)]
pub struct GlyphFragment {
    /// A unique id.
    pub id: GlyphId,

    /// The base character.
    pub c: char,

    /// A font family descriptor or priority list of font family descriptor.
    ///
    /// This works much akin to how fonts are specified for [TextElem], but for modification
    /// a show rule must be used.
    ///
    /// ```example
    /// #show math.equation: set text(font: "Fira Math")
    /// $ f i r a m a t h $
    /// ```
    pub font: Font,

    /// An [ISO 639-1/2/3 language code.](https://en.wikipedia.org/wiki/ISO_639)
    ///
    /// See [TextElem]
    pub lang: Lang,

    /// An [ISO 3166-1 alpha-2 region code.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
    ///
    /// See [TextElem]
    pub region: Option<Region>,

    /// The glyph fill paint.
    ///
    /// ```example
    /// #show math.equation: set text(fill: red)
    /// $ r e d $

Review comment (suggestion):
This field isn't quite the same as the one on `TextElem`, which is a list of font families. It's just a single/lone OpenType font.

Code after:
        Self::Glyph(glyph)
    }
}

impl From<VariantFragment> for MathFragment {
    fn from(variant: VariantFragment) -> Self {
        Self::Variant(variant)
    }
}

impl From<FrameFragment> for MathFragment {
    fn from(fragment: FrameFragment) -> Self {
        Self::Frame(fragment)
    }
}

#[derive(Clone)]
pub struct GlyphFragment {
    pub id: GlyphId,
    pub c: char,
    pub font: Font,
    pub lang: Lang,
    pub region: Option<Region>,
    pub fill: Paint,
    pub stroke: Option<FixedStroke>,
    pub shift: Abs,
    pub width: Abs,
    pub ascent: Abs,
    pub descent: Abs,
    pub italics_correction: Abs,
    pub accent_attach: Abs,
    pub font_size: Abs,
    pub class: MathClass,
    pub math_size: MathSize,
    pub span: Span,
    pub modifiers: FrameModifiers,
    pub limits: Limits,
    pub extended_shape: bool,
}

impl GlyphFragment {
    pub fn new(ctx: &MathContext, styles: StyleChain, c: char, span: Span) -> Self {
        let id = ctx.ttf.glyph_index(c).unwrap_or_default();
        let id = Self::adjust_glyph_index(ctx, id);
        Self::with_id(ctx, styles, c, id, span)
    }

    pub fn try_new(
        ctx: &MathContext,
        styles: StyleChain,
        c: char,
Repository: typst/typst
File: crates/typst-svg/src/lib.rs (Rust)

Code before:
            f,
            "matrix({} {} {} {} {} {})",
            self.0.sx.get(),
            self.0.ky.get(),
            self.0.kx.get(),
            self.0.sy.get(),
            self.0.tx.to_pt(),
            self.0.ty.to_pt()
        )
    }
}

/// A builder for SVG path using relative coordinates.
struct SvgRelativePathBuilder {
    pub path: EcoString,
    pub scale: Ratio,
    pub last_point: Point,
}

impl SvgRelativePathBuilder {
    fn with_translate(pos: Point) -> Self {
        // add initial M node to transform the entire path
        Self {
            path: EcoString::from(format!("M {} {}", pos.x.to_pt(), pos.y.to_pt())),
            scale: Ratio::one(),
            last_point: Point::zero(),
        }
    }

    fn scale(&self) -> f32 {
        self.scale.get() as f32
    }

    fn last_point(&self) -> Point {
        self.last_point
    }

    fn map_x(&self, x: f32) -> f32 {
        x * self.scale() - self.last_point().x.to_pt() as f32
    }

    fn map_y(&self, y: f32) -> f32 {
        y * self.scale() - self.last_point().y.to_pt() as f32
    }

    /// Create a rectangle path. The rectangle is created with the top-left
    /// corner at (0, 0). The width and height are the size of the rectangle.
    fn rect(&mut self, width: f32, height: f32) {
        self.move_to(0.0, 0.0);
        self.line_to(0.0, height);
        self.line_to(width, height);

Review comment (suggestion):
If the initial point is zero, we could skip the `M 0 0` (I think?). this happens a lot in the tests.

Code after:
        write!(
            f,
            "matrix({} {} {} {} {} {})",
            self.0.sx.get(),
            self.0.ky.get(),
            self.0.kx.get(),
            self.0.sy.get(),
            self.0.tx.to_pt(),
            self.0.ty.to_pt()
        )
    }
}

/// A builder for SVG path using relative coordinates.
struct SvgPathBuilder {
    pub path: EcoString,
    pub scale: Ratio,
    pub last_close_point: Point,
    pub last_point: Point,
}

impl SvgPathBuilder {
    fn with_translate(pos: Point) -> Self {
        // add initial M node to transform the entire path
        Self {
            path: EcoString::from(format!("M {} {}", pos.x.to_pt(), pos.y.to_pt())),
            scale: Ratio::one(),
            last_close_point: pos,
            last_point: Point::zero(),
        }
    }

    fn with_scale(scale: Ratio) -> Self {
        Self {
            path: EcoString::from("M 0 0"),
            scale,
            last_close_point: Point::zero(),
            last_point: Point::zero(),
        }
    }

    fn scale(&self) -> f32 {
        self.scale.get() as f32
    }

    fn set_point(&mut self, x: f32, y: f32) {
        let point = Point::new(
            Abs::pt(f64::from(x * self.scale())),
            Abs::pt(f64::from(y * self.scale())),
        );
Repository: typst/typst
File: crates/typst-library/src/math/style.rs (Rust)

Code before:
///
/// ```example
/// $ scr(S) $
/// ```
///
/// There are two ways that fonts can support differentiating `cal` and `scr`.
/// The first is using Unicode variation sequences. This works out of the box
/// in Typst, however only a few math fonts currently support this.
///
/// The other way is using [font features]($text.features). For example, the
/// roundhand style might be available in a font through the `ss01` feature.
/// To use it in Typst, you could then define your own version of `scr` like
/// this:
///
/// ```example
/// #let scr(it) = text(
///   features: ("ss01",),
///   box($cal(it)$),
/// )
///
/// We establish $cal(P) != scr(P)$.
/// ```
///
/// (The box is not conceptually necessary, but unfortunately currently needed
/// due to limitations in Typst's text style handling in math.)
#[func(title = "Script", keywords = ["mathscr", "roundhand"])]
pub fn scr(
    /// The content to style.
    body: Content,
) -> Content {
    body.styled(EquationElem::set_variant(Some(MathVariant::Roundhand)))
}

/// Fraktur font style in math.
///
/// ```example
/// $ frak(P) $
/// ```
#[func(title = "Fraktur", keywords = ["mathfrak"])]
pub fn frak(
    /// The content to style.
    body: Content,
) -> Content {
    body.styled(EquationElem::set_variant(Some(MathVariant::Fraktur)))
}

/// Monospace font style in math.
///
/// ```example
/// $ mono(x + y = z) $
/// ```

Review comment (suggestion):
```suggestion
#[func(title = "Script Style", keywords = ["mathscr", "roundhand"])]
```

This is probably better for clarity (`math.script` is "Script Size").

Code after:
///
/// ```example
/// $ scr(S) $
/// ```
///
/// There are two ways that fonts can support differentiating `cal` and `scr`.
/// The first is using Unicode variation sequences. This works out of the box
/// in Typst, however only a few math fonts currently support this.
///
/// The other way is using [font features]($text.features). For example, the
/// roundhand style might be available in a font through the `ss01` feature.
/// To use it in Typst, you could then define your own version of `scr` like
/// this:
///
/// ```example
/// #let scr(it) = text(
///   features: ("ss01",),
///   box($cal(it)$),
/// )
///
/// We establish $cal(P) != scr(P)$.
/// ```
///
/// (The box is not conceptually necessary, but unfortunately currently needed
/// due to limitations in Typst's text style handling in math.)
#[func(title = "Script Style", keywords = ["mathscr", "roundhand"])]
pub fn scr(
    /// The content to style.
    body: Content,
) -> Content {
    body.set(EquationElem::variant, Some(MathVariant::Roundhand))
}

/// Fraktur font style in math.
///
/// ```example
/// $ frak(P) $
/// ```
#[func(title = "Fraktur", keywords = ["mathfrak"])]
pub fn frak(
    /// The content to style.
    body: Content,
) -> Content {
    body.set(EquationElem::variant, Some(MathVariant::Fraktur))
}

/// Monospace font style in math.
///
/// ```example
/// $ mono(x + y = z) $
/// ```
Repository: typst/typst
File: crates/typst-library/src/foundations/label.rs (Rust)

Code before:
    pub fn new(name: PicoStr) -> Self {
        debug_assert!(name != PicoStr::EMPTY);
        Self(name)
    }

    /// Resolves the label to a string.
    pub fn resolve(self) -> ResolvedPicoStr {
        self.0.resolve()
    }

    /// Turns this label into its inner interned string.
    pub fn into_inner(self) -> PicoStr {
        self.0
    }
}

#[scope]
impl Label {
    /// Creates a label from a string. Fails for empty strings.
    #[func(constructor)]
    pub fn construct(
        /// The name of the label.
        name: Str,
    ) -> StrResult<Label> {
        if name.is_empty() {
            bail!("expected non-empty label name");
        }

        Ok(Self(PicoStr::intern(name.as_str())))
    }
}

impl Repr for Label {
    fn repr(&self) -> EcoString {
        eco_format!("<{}>", self.resolve())
    }
}

impl From<Label> for PicoStr {
    fn from(value: Label) -> Self {
        value.into_inner()
    }
}

/// Indicates that an element cannot be labelled.
pub trait Unlabellable {}


Review comment (suggestion):
```suggestion
            bail!("label name must not be empty");
```

Code after:
        const EMPTY: PicoStr = PicoStr::constant("");
        (name != EMPTY).then_some(Self(name))
    }

    /// Resolves the label to a string.
    pub fn resolve(self) -> ResolvedPicoStr {
        self.0.resolve()
    }

    /// Turns this label into its inner interned string.
    pub fn into_inner(self) -> PicoStr {
        self.0
    }
}

#[scope]
impl Label {
    /// Creates a label from a string.
    #[func(constructor)]
    pub fn construct(
        /// The name of the label. Must not be empty.
        name: Str,
    ) -> StrResult<Label> {
        if name.is_empty() {
            bail!("label name must not be empty");
        }

        Ok(Self(PicoStr::intern(name.as_str())))
    }
}

impl Repr for Label {
    fn repr(&self) -> EcoString {
        eco_format!("<{}>", self.resolve())
    }
}

impl From<Label> for PicoStr {
    fn from(value: Label) -> Self {
        value.into_inner()
    }
}

/// Indicates that an element cannot be labelled.
pub trait Unlabellable {}
Repository: typst/typst
File: crates/typst-library/src/foundations/label.rs (Rust)

Code before:
use ecow::{eco_format, EcoString};
use typst_utils::{PicoStr, ResolvedPicoStr};

use crate::{
    diag::StrResult,
    foundations::{bail, func, scope, ty, Repr, Str},
};

/// A label for an element.
///
/// Inserting a label into content attaches it to the closest preceding element
/// that is not a space. The preceding element must be in the same scope as the
/// label, which means that `[Hello #[<label>]]`, for instance, wouldn't work.
///
/// A labelled element can be [referenced]($ref), [queried]($query) for, and
/// [styled]($styling) through its label.
///
/// Once constructed, you can get the name of a label using
/// [`str`]($str/#constructor).
///
/// # Example
/// ```example
/// #show <a>: set text(blue)
/// #show label("b"): set text(red)
///
/// = Heading <a>
/// *Strong* #label("b")
/// ```
///
/// # Syntax
/// This function also has dedicated syntax: You can create a label by enclosing
/// its name in angle brackets. This works both in markup and code. A label's

Review comment (suggestion):
```suggestion
use crate::{
    diag::StrResult,
    foundations::{bail, func, scope, ty, Repr, Str},
};
```
please ungroup these imports

Code after:
use ecow::{eco_format, EcoString};
use typst_utils::{PicoStr, ResolvedPicoStr};

use crate::diag::StrResult;
use crate::foundations::{bail, func, scope, ty, Repr, Str};

/// A label for an element.
///
/// Inserting a label into content attaches it to the closest preceding element
/// that is not a space. The preceding element must be in the same scope as the
/// label, which means that `[Hello #[<label>]]`, for instance, wouldn't work.
///
/// A labelled element can be [referenced]($ref), [queried]($query) for, and
/// [styled]($styling) through its label.
///
/// Once constructed, you can get the name of a label using
/// [`str`]($str/#constructor).
///
/// # Example
/// ```example
/// #show <a>: set text(blue)
/// #show label("b"): set text(red)
///
/// = Heading <a>
/// *Strong* #label("b")
/// ```
///
/// # Syntax
/// This function also has dedicated syntax: You can create a label by enclosing
/// its name in angle brackets. This works both in markup and code. A label's
/// name can contain letters, numbers, `_`, `-`, `:`, and `.`. A label cannot
/// be empty.
Repository: typst/typst
File: crates/typst-library/src/foundations/mod.rs (Rust)

Code before:
    ) -> StrResult<NoneValue> {
        if left == right {
            if let Some(message) = message {
                bail!("inequality assertion failed: {message}");
            } else {
                bail!(
                    "inequality assertion failed: value {} was equal to {}",
                    left.repr(),
                    right.repr()
                );
            }
        }
        Ok(NoneValue)
    }
}

cast! {
    SyntaxMode,
    self => match self {
        SyntaxMode::Markup => "markup".into_value(),
        SyntaxMode::Math => "math".into_value(),
        SyntaxMode::Code => "code".into_value(),
    },
    "markup" => SyntaxMode::Markup,
    "math" => SyntaxMode::Math,
    "code" => SyntaxMode::Code,
}

/// Evaluates a string as Typst code.
///
/// This function should only be used as a last resort.
///
/// # Example
/// ```example
/// #eval("1 + 1") \
/// #eval("(1, 2, 3, 4)").len() \
/// #eval("*Markup!*", mode: "markup") \
/// ```
#[func(title = "Evaluate")]
pub fn eval(
    engine: &mut Engine,
    /// A string of Typst code to evaluate.
    source: Spanned<String>,
    /// The [syntactical mode]($reference/syntax/#modes) in which the string is
    /// parsed.
    ///
    /// ```example
    /// #eval("= Heading", mode: "markup")
    /// #eval("1_2^3", mode: "math")
    /// ```
    #[named]

Review comment (refactor):
Please add `///` doc comments above each match arm here. Previously this was taken from the enum via `derive(Cast)`. It's what shows up in the table on https://typst.app/docs/reference/foundations/eval/#parameters-mode.

As for the location, we could move this to `cast.rs`, right above the `cast!` for `MathClass`.

Code after:
    ) -> StrResult<NoneValue> {
        if left == right {
            if let Some(message) = message {
                bail!("inequality assertion failed: {message}");
            } else {
                bail!(
                    "inequality assertion failed: value {} was equal to {}",
                    left.repr(),
                    right.repr()
                );
            }
        }
        Ok(NoneValue)
    }
}

/// Evaluates a string as Typst code.
///
/// This function should only be used as a last resort.
///
/// # Example
/// ```example
/// #eval("1 + 1") \
/// #eval("(1, 2, 3, 4)").len() \
/// #eval("*Markup!*", mode: "markup") \
/// ```
#[func(title = "Evaluate")]
pub fn eval(
    engine: &mut Engine,
    /// A string of Typst code to evaluate.
    source: Spanned<String>,
    /// The [syntactical mode]($reference/syntax/#modes) in which the string is
    /// parsed.
    ///
    /// ```example
    /// #eval("= Heading", mode: "markup")
    /// #eval("1_2^3", mode: "math")
    /// ```
    #[named]
    #[default(SyntaxMode::Code)]
    mode: SyntaxMode,
    /// A scope of definitions that are made available.
    ///
    /// ```example
    /// #eval("x + 1", scope: (x: 2)) \
    /// #eval(
    ///   "abc/xyz",
    ///   mode: "math",
    ///   scope: (
    ///     abc: $a + b + c$,
    ///     xyz: $x + y + z$,