From bfaf5447a789cd0dbbb1e418bea62fef9edc2b7d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 6 May 2022 10:05:11 +0200 Subject: Cast content from string --- src/eval/func.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/eval/func.rs') diff --git a/src/eval/func.rs b/src/eval/func.rs index b72e9f18..73f2cac9 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -43,11 +43,11 @@ impl Func { Self(Arc::new(Repr::Native(Native { name, func: |ctx, args| { - let styles = T::set(args)?; + let styles = T::set(args, true)?; let content = T::construct(ctx, args)?; Ok(Value::Content(content.styled_with_map(styles.scoped()))) }, - set: Some(T::set), + set: Some(|args| T::set(args, false)), node: T::SHOWABLE.then(|| NodeId::of::()), }))) } @@ -165,7 +165,10 @@ pub trait Node: 'static { fn construct(ctx: &mut Context, args: &mut Args) -> TypResult; /// Parse the arguments into style properties for this node. - fn set(args: &mut Args) -> TypResult; + /// + /// When `constructor` is true, [`construct`](Self::construct) will run + /// after this invocation of `set`. + fn set(args: &mut Args, constructor: bool) -> TypResult; } /// A user-defined closure. -- cgit v1.2.3