summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eval/mod.rs16
-rw-r--r--src/library/layout/page.rs2
-rw-r--r--src/library/structure/list.rs2
-rw-r--r--src/model/recipe.rs4
4 files changed, 8 insertions, 16 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index db50ee82..d39c3c2c 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -354,7 +354,7 @@ fn eval_code(
break;
}
- let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?;
+ let tail = eval_code(ctx, scp, exprs)?.display();
Value::Content(tail.styled_with_map(styles))
}
Expr::Show(show) => {
@@ -364,12 +364,12 @@ fn eval_code(
break;
}
- let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?;
+ let tail = eval_code(ctx, scp, exprs)?.display();
Value::Content(tail.styled_with_entry(entry))
}
Expr::Wrap(wrap) => {
- let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?;
- scp.top.def_mut(wrap.binding().take(), Value::Content(tail));
+ let tail = eval_code(ctx, scp, exprs)?;
+ scp.top.def_mut(wrap.binding().take(), tail);
wrap.body().eval(ctx, scp)?
}
@@ -386,14 +386,6 @@ fn eval_code(
Ok(output)
}
-/// Extract content from a value.
-fn to_content(value: Value) -> StrResult<Content> {
- let ty = value.type_name();
- value
- .cast()
- .map_err(|_| format!("expected remaining block to yield content, found {ty}"))
-}
-
impl Eval for ContentBlock {
type Output = Content;
diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs
index 324ac285..ed9a03a4 100644
--- a/src/library/layout/page.rs
+++ b/src/library/layout/page.rs
@@ -159,7 +159,7 @@ impl Marginal {
Self::Content(content) => Some(content.clone()),
Self::Func(func, span) => {
let args = Args::from_values(*span, [Value::Int(page as i64)]);
- func.call(ctx, args)?.cast().at(*span)?
+ Some(func.call(ctx, args)?.display())
}
})
}
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index 6bcc9f3e..7686a3f4 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -217,7 +217,7 @@ impl Label {
Self::Content(content) => content.clone(),
Self::Func(func, span) => {
let args = Args::from_values(*span, [Value::Int(number as i64)]);
- func.call(ctx, args)?.cast().at(*span)?
+ func.call(ctx, args)?.display()
}
})
}
diff --git a/src/model/recipe.rs b/src/model/recipe.rs
index 905e035e..3404a384 100644
--- a/src/model/recipe.rs
+++ b/src/model/recipe.rs
@@ -1,7 +1,7 @@
use std::fmt::{self, Debug, Formatter};
use super::{Content, Interruption, NodeId, Show, ShowNode, StyleChain, StyleEntry};
-use crate::diag::{At, TypResult};
+use crate::diag::TypResult;
use crate::eval::{Args, Func, Regex, Value};
use crate::library::structure::{EnumNode, ListNode};
use crate::syntax::Span;
@@ -87,7 +87,7 @@ impl Recipe {
Args::from_values(self.span, [arg()])
};
- self.func.call(ctx, args)?.cast().at(self.span)
+ Ok(self.func.call(ctx, args)?.display())
}
/// What kind of structure the property interrupts.