summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-25 13:50:33 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-25 13:59:06 +0200
commitc010cbc17dcbb2f0d6005d21530143bf57cb5871 (patch)
tree937fe79f0c121bcc025480181287fd4a3d0c0f4f /src/model
parent6935cf8dfefff3d6cf234f077a7d61661fd5ca57 (diff)
Move route from context to VM
Diffstat (limited to 'src/model')
-rw-r--r--src/model/content.rs26
-rw-r--r--src/model/mod.rs2
-rw-r--r--src/model/recipe.rs6
3 files changed, 17 insertions, 17 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 64579747..c09979d5 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -19,6 +19,19 @@ use crate::library::text::{
};
use crate::util::EcoString;
+/// Layout content into a collection of pages.
+pub fn layout(ctx: &mut Context, content: &Content) -> TypResult<Vec<Arc<Frame>>> {
+ let copy = ctx.config.styles.clone();
+ let styles = StyleChain::with_root(&copy);
+ let scratch = Scratch::default();
+
+ let mut builder = Builder::new(ctx, &scratch, true);
+ builder.accept(content, styles)?;
+
+ let (doc, shared) = builder.into_doc(styles)?;
+ doc.layout(ctx, shared)
+}
+
/// Composable representation of styled content.
///
/// This results from:
@@ -207,19 +220,6 @@ impl Content {
Self::sequence(seq)
}
-
- /// Layout this content into a collection of pages.
- pub fn layout(&self, ctx: &mut Context) -> TypResult<Vec<Arc<Frame>>> {
- let copy = ctx.config.styles.clone();
- let styles = StyleChain::with_root(&copy);
- let scratch = Scratch::default();
-
- let mut builder = Builder::new(ctx, &scratch, true);
- builder.accept(self, styles)?;
-
- let (doc, shared) = builder.into_doc(styles)?;
- doc.layout(ctx, shared)
- }
}
impl Layout for Content {
diff --git a/src/model/mod.rs b/src/model/mod.rs
index a9d1344a..5c8b82c0 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -1,4 +1,4 @@
-//! Structured representation of styled content.
+//! Styled and structured representation of layoutable content.
#[macro_use]
mod styles;
diff --git a/src/model/recipe.rs b/src/model/recipe.rs
index 3404a384..e4417adf 100644
--- a/src/model/recipe.rs
+++ b/src/model/recipe.rs
@@ -82,12 +82,12 @@ impl Recipe {
F: FnOnce() -> Value,
{
let args = if self.func.argc() == Some(0) {
- Args::new(self.span)
+ Args::new(self.span, [])
} else {
- Args::from_values(self.span, [arg()])
+ Args::new(self.span, [arg()])
};
- Ok(self.func.call(ctx, args)?.display())
+ Ok(self.func.call_detached(ctx, args)?.display())
}
/// What kind of structure the property interrupts.