summaryrefslogtreecommitdiff
path: root/src/eval/func.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-06 10:05:11 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-06 10:05:11 +0200
commitbfaf5447a789cd0dbbb1e418bea62fef9edc2b7d (patch)
tree0cc1a47b37439fbeda06c57ebef0025becae0066 /src/eval/func.rs
parent49b8574b8d03e52a990f7d7b009c36fbdad0d55a (diff)
Cast content from string
Diffstat (limited to 'src/eval/func.rs')
-rw-r--r--src/eval/func.rs9
1 files changed, 6 insertions, 3 deletions
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::<T>()),
})))
}
@@ -165,7 +165,10 @@ pub trait Node: 'static {
fn construct(ctx: &mut Context, args: &mut Args) -> TypResult<Content>;
/// Parse the arguments into style properties for this node.
- fn set(args: &mut Args) -> TypResult<StyleMap>;
+ ///
+ /// When `constructor` is true, [`construct`](Self::construct) will run
+ /// after this invocation of `set`.
+ fn set(args: &mut Args, constructor: bool) -> TypResult<StyleMap>;
}
/// A user-defined closure.