mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add delimiter setting for cases
This commit is contained in:
parent
10b17a04bc
commit
a8f2e85f96
@ -159,6 +159,14 @@ pub struct CasesNode(Vec<Content>);
|
|||||||
|
|
||||||
#[node]
|
#[node]
|
||||||
impl CasesNode {
|
impl CasesNode {
|
||||||
|
/// The delimiter to use.
|
||||||
|
///
|
||||||
|
/// ```example
|
||||||
|
/// #set math.cases(delim: "[")
|
||||||
|
/// $ x = cases(1, 2) $
|
||||||
|
/// ```
|
||||||
|
pub const DELIM: Delimiter = Delimiter::Brace;
|
||||||
|
|
||||||
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
|
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
|
||||||
Ok(Self(args.all()?).pack())
|
Ok(Self(args.all()?).pack())
|
||||||
}
|
}
|
||||||
@ -166,8 +174,9 @@ impl CasesNode {
|
|||||||
|
|
||||||
impl LayoutMath for CasesNode {
|
impl LayoutMath for CasesNode {
|
||||||
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
|
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
|
||||||
|
let delim = ctx.styles().get(Self::DELIM);
|
||||||
let frame = layout_vec_body(ctx, &self.0, Align::Left)?;
|
let frame = layout_vec_body(ctx, &self.0, Align::Left)?;
|
||||||
layout_delimiters(ctx, frame, Some('{'), None)
|
layout_delimiters(ctx, frame, Some(delim.open()), None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user