Repository: typst/typst
File: crates/typst-library/src/math/lr.rs (Rust)

Code before:
    delimited(body, '|', '|', size)
}

/// Takes the norm of an expression.
///
/// ```example
/// $ norm(x/2) $
/// ```
#[func]
pub fn norm(
    /// The size of the brackets, relative to the height of the wrapped content.
    ///
    /// Default: The current value of [`lr.size`]($math.lr.size).
    #[named]
    size: Option<Rel<Length>>,
    /// The expression to take the norm of.
    body: Content,
) -> Content {
    delimited(body, '‖', '‖', size)
}

/// Gets the Left/Right wrapper function corresponding to a left delimiter, if
/// any.
pub fn get_lr_wrapper_func(left: char) -> Option<Func> {
    match left {
        // Unlike `round`, `abs`, and `norm`, floor` and `ceil` are of type
        // `symbol` and cast to a function like other L/R symbols. We could thus
        // rely on autogeneration for these as well, but since they are
        // specifically called out in the documentation on the L/R page (via the
        // group mechanism), it's nice for them to have a bit of extra
        // documentation.
        '⌈' => Some(ceil::func()),
        '⌊' => Some(floor::func()),
        l => FUNCS.get(&l).map(Func::from),
    }
}

/// The delimiter pairings supported for use as callable symbols.
const DELIMS: &[(char, char)] = &[
    // The `ceil` and `floor` pairs are omitted here because they are handled
    // manually.
    ('⌈', '⌉'),
    ('⌊', '⌋'),
    ('(', ')'),
    ('⟮', '⟯'),
    ('⦇', '⦈'),
    ('⦅', '⦆'),
    ('⦓', '⦔'),
    ('⦕', '⦖'),
    ('{', '}'),
    ('⦃', '⦄'),

Review comment (suggestion):
```suggestion
        // Unlike `round`, `abs`, and `norm`, `floor` and `ceil` are of type
```

Code after:
    delimited(body, '|', '|', size)
}

/// Takes the norm of an expression.
///
/// ```example
/// $ norm(x/2) $
/// ```
#[func]
pub fn norm(
    /// The size of the brackets, relative to the height of the wrapped content.
    ///
    /// Default: The current value of [`lr.size`]($math.lr.size).
    #[named]
    size: Option<Rel<Length>>,
    /// The expression to take the norm of.
    body: Content,
) -> Content {
    delimited(body, '‖', '‖', size)
}

/// Gets the Left/Right wrapper function corresponding to a left delimiter, if
/// any.
pub fn get_lr_wrapper_func(left: char) -> Option<Func> {
    match left {
        // Unlike `round`, `abs`, and `norm`, `floor` and `ceil` are of type
        // `symbol` and cast to a function like other L/R symbols. We could thus
        // rely on autogeneration for these as well, but since they are
        // specifically called out in the documentation on the L/R page (via the
        // group mechanism), it's nice for them to have a bit of extra
        // documentation.
        '⌈' => Some(ceil::func()),
        '⌊' => Some(floor::func()),
        l => FUNCS.get(&l).map(Func::from),
    }
}

/// The delimiter pairings supported for use as callable symbols.
const DELIMS: &[(char, char)] = &[
    // The `ceil` and `floor` pairs are omitted here because they are handled
    // manually.
    ('(', ')'),
    ('⟮', '⟯'),
    ('⦇', '⦈'),
    ('⦅', '⦆'),
    ('⦓', '⦔'),
    ('⦕', '⦖'),
    ('{', '}'),
    ('⦃', '⦄'),
    ('[', ']'),
    ('⦍', '⦐'),